Back to home page

EIC code displayed by LXR

 
 

    


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

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 <cassert>
0021 #include "SArgs.hh"
0022 
0023 #include "OPTICKS_LOG.hh"
0024 
0025 
0026 void test_argforced(int argc, char** argv)
0027 {
0028     const char* argforced = "--compute --nopropagate --tracer --nogdmlpath" ;
0029     //const char* argforced = "--nogdmlpath" ;
0030     const char* opts = nullptr ; 
0031 
0032     SArgs* sa = new SArgs(argc, argv, argforced, opts );
0033 
0034     std::cout << " sa->argc " << sa->argc << std::endl ; 
0035     sa->dump();
0036 
0037     assert(sa->hasArg("--compute"));
0038     assert(sa->hasArg("--nopropagate"));
0039     assert(sa->hasArg("--tracer"));
0040     assert(sa->hasArg("--nogdmlpath"));
0041 }
0042 
0043 
0044 void test_starts_with()
0045 {
0046     std::string e = "--hello" ;  
0047     std::string f = "hello" ;  
0048     assert( SArgs::starts_with(e,"--") == true ) ;
0049     assert( SArgs::starts_with(f,"--") == false ) ;
0050 }
0051 
0052 void test_get_first_arg_ending_with(int argc, char** argv)
0053 {
0054     const char* extra = "--red --green path/to/geometry.gdmlx --blue another.gdml" ;
0055     const char* opts = "--pink slip" ; 
0056     SArgs* sa = new SArgs(argc, argv, extra, opts );
0057     const char* arg = sa->get_first_arg_ending_with(".gdml", NULL ); 
0058     LOG(info) << arg ; 
0059 }
0060 
0061 
0062 int main(int argc, char** argv)
0063 {
0064     OPTICKS_LOG(argc, argv);
0065 
0066     test_starts_with(); 
0067     test_argforced(argc, argv); 
0068 
0069     //test_get_first_arg_ending_with( argc, argv ); 
0070 
0071     return 0 ; 
0072 }
0073 /*
0074 The below should be deduped:
0075 
0076     SArgsTest  --tracer --compute
0077     SArgsTest  --tracer --compute --nopropagate   
0078 
0079 Deduping only has effect between the argforced "extra" additions
0080 and the ordinary args, it does not dedupe the standard args.
0081 
0082 */