Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:18

0001 // ./SLabel_test.sh
0002 #include <iostream>
0003 #include <iomanip>
0004 #include <cstring>
0005 #include <string>
0006 
0007 #include "SLabel.h"
0008 
0009 void test_GEOMLoad()
0010 {
0011     SLabel* id = SLabel::GEOMLoad(); 
0012     std::cout 
0013         << "test_GEOMLoad"
0014         << std::endl 
0015         << "SLabel* id = SLabel::GEOMLoad() ; id->detail() " 
0016         << std::endl 
0017         << id->detail()
0018         << std::endl 
0019         ; 
0020 }
0021 
0022 
0023 void test_findIndicesWithListedLabels_one_by_one()
0024 {
0025     SLabel* id = SLabel::GEOMLoad(); 
0026     for(unsigned i=0 ; i < id->label.size() ; i++)
0027     {
0028         std::vector<unsigned> indices ; 
0029         id->findIndicesWithListedLabels(indices, id->label[i].c_str(), ',' ); 
0030         assert( indices.size() == 1 && indices[0] == i );  
0031     }
0032 }
0033 
0034 void test_findIndicesWithListedLabels_all()
0035 {
0036     SLabel* id = SLabel::GEOMLoad(); 
0037 
0038     char delim = ',' ; 
0039 
0040     unsigned num_label = id->label.size() ; 
0041     std::stringstream ss ; 
0042     for(unsigned i=0 ; i < num_label ; i++)
0043     {
0044         ss << id->label[i].c_str() << ( i < num_label - 1 ? delim : '\0' ) ; 
0045     }
0046 
0047     std::string _ls = ss.str(); 
0048     const char* ls = _ls.c_str(); 
0049 
0050     std::cout << "[" << ls << "]\n" ;  
0051 
0052     std::vector<unsigned> indices ; 
0053     id->findIndicesWithListedLabels(indices, ls, delim ); 
0054     assert( indices.size() == num_label );  
0055 }
0056 
0057 void test_IsIdxLabelListed()
0058 {
0059     SLabel* id = SLabel::GEOMLoad(); 
0060 
0061     char delim = ',' ; 
0062     std::vector<std::string> labs ; 
0063     unsigned num_label = id->label.size() ; 
0064     for(unsigned i=0 ; i < num_label ; i++)
0065     {
0066         if(i % 2 == 0) labs.push_back( id->label[i].c_str() ); 
0067     }
0068 
0069     unsigned num_labs = labs.size(); 
0070     std::stringstream ss ; 
0071     for(unsigned i=0 ; i < num_labs ; i++)
0072     {
0073         ss << labs[i].c_str() << ( i < num_labs - 1 ? delim : '\0' ) ;     
0074     } 
0075     std::string _ls = ss.str(); 
0076     const char* ls = _ls.c_str(); 
0077     std::cout << ls << "\n" ; 
0078 
0079     for(unsigned i=0 ; i < num_label ; i++)
0080     {
0081         bool listed = SLabel::IsIdxLabelListed(id->label, i, ls, ',' ); 
0082         std::cout << " i " << i << " listed " << ( listed ? "Y" : "N" ) << " " << id->label[i] << "\n" ;  
0083     }
0084 }
0085 
0086 
0087 
0088 
0089 
0090 int main()
0091 {
0092     //test_GEOMLoad(); 
0093     //test_findIndicesWithListedLabels_one_by_one(); 
0094     //test_findIndicesWithListedLabels_all(); 
0095 
0096     test_IsIdxLabelListed();
0097 
0098 
0099     return 0 ; 
0100 }