Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*
0002  * Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003  *
0004  * This file is part of Opticks
0005  * (see https://bitbucket.org/simoncblyth/opticks).
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License"); 
0008  * you may not use this file except in compliance with the License.  
0009  * You may obtain a copy of the License at
0010  *
0011  *   http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software 
0014  * distributed under the License is distributed on an "AS IS" BASIS, 
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016  * See the License for the specific language governing permissions and 
0017  * limitations under the License.
0018  */
0019 
0020 #include "OPTICKS_LOG.hh"
0021 #include "SGDML.hh"
0022 
0023 
0024 struct Demo
0025 {
0026    int answer ;
0027 };
0028 
0029 
0030 void test_GenerateName()
0031 {
0032     Demo* d = new Demo { 42 } ; 
0033     LOG(info) << SGDML::GenerateName( "Demo", d, true );
0034 }
0035 
0036 
0037 
0038 void test_Strip()
0039 {
0040     LOG(info) ; 
0041     std::vector<std::string> names  = { "hell0xc0ffee" , "world0xdeadbeef", "hello0xworld0xcruel", "0xhello", "name_without_0X_lowercase",  } ; 
0042     std::vector<std::string> xnames = { "hell" ,         "world",           "hello",               ""       , "name_without_0X_lowercase"} ; 
0043     
0044     for(int i=0 ; i < int(names.size()) ; i++)
0045     {
0046        const std::string& xname = xnames[i] ; 
0047        const std::string& name = names[i] ; 
0048        std::string sname = SGDML::Strip(name) ; 
0049        std::string sname2 = SGDML::Strip(name.c_str()) ; 
0050 
0051        std::cout 
0052            << std::setw(3) << i 
0053            << " : "
0054            << std::setw(50) << name
0055            << " : "
0056            << std::setw(50) << sname
0057            << " : "
0058            << std::setw(50) << xname
0059            << std::endl
0060            ;
0061 
0062         assert( strcmp(xname.c_str(), sname.c_str()) == 0 );  
0063         assert( strcmp(sname.c_str(), sname2.c_str()) == 0 );  
0064     }
0065 }
0066 
0067 
0068 
0069 int main(int argc, char** argv)
0070 {   
0071     OPTICKS_LOG(argc, argv);
0072 
0073     test_GenerateName(); 
0074     test_Strip(); 
0075  
0076     return 0 ;
0077 }   
0078 
0079 // om-;TEST=SGDMLTest om-t 
0080