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 // TEST=SASCIITest om-t
0021 
0022 #include <string>
0023 #include <vector>
0024 
0025 #include "SDice.hh"
0026 #include "SASCII.hh"
0027 #include "SAbbrev.hh"
0028 
0029 #include "OPTICKS_LOG.hh"
0030 
0031 void test_0()
0032 {
0033     SASCII::DumpAllowed(); 
0034 
0035     const char* s = "Hello_World_0" ; 
0036     SASCII n(s) ; 
0037     assert( n.upper == 2 && n.lower == 8 && n.other == 2 && n.number == 1 ) ; 
0038 
0039     std::vector<std::string> ss = { 
0040         "Acrylic",
0041         "Air", 
0042         "Aluminium",
0043         "Bialkali",
0044         "DeadWater",
0045         "ESR",
0046         "Foam",
0047         "GdDopedLS",
0048         "IwsWater",
0049         "LiquidScintillator",
0050         "MineralOil",
0051         "Nitrogen",
0052         "NitrogenGas",
0053         "Nylon",
0054         "OwsWater",
0055         "PPE",
0056         "PVC",
0057         "Pyrex",
0058         "Rock",
0059         "StainlessSteel",
0060         "Tyvek",
0061         "UnstStainlessSteel",
0062         "Vacuum",
0063         "OpaqueVacuum",
0064         "Water",
0065         "GlassSchottF2"
0066     } ;
0067 
0068 
0069     for(unsigned i=0 ; i < ss.size() ; i++)
0070     {
0071         SASCII n(ss[i].c_str());  
0072         std::cout 
0073               << std::setw(30) << n.s 
0074               << " firstUpper(1) " << std::setw(5) << n.getFirstUpper(1) 
0075               << " firstUpper(2) " << std::setw(5) << n.getFirstUpper(2) 
0076               << " firstUpper(3) " << std::setw(5) << n.getFirstUpper(3) 
0077               << " firstUpper(4) " << std::setw(5) << n.getFirstUpper(4)
0078               << std::endl ;  
0079     }
0080 }
0081 
0082 
0083 void test_dump()
0084 {
0085     SASCII n("Hello"); 
0086     n.dump(); 
0087 
0088     SDice<26> rng ; 
0089 
0090     for(unsigned i=0 ; i < 10 ; i++)
0091     {
0092         std::string ab = n.getTwoRandom(rng); 
0093         std::cout << ab << std::endl ; 
0094     }
0095 
0096 }
0097 
0098 void test_UpperIndex()
0099 {
0100     const char* upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; 
0101     for(unsigned i=0 ; i < strlen(upper) ; i++)
0102     {
0103         char c = upper[i] ; 
0104         int ui = SASCII::UpperIndex(c) ; 
0105         std::cout 
0106             << " i: " << std::setw(2) << i 
0107             << " c: " << std::setw(2) << c 
0108             << " ui: " << std::setw(2) << ui
0109             << std::endl
0110             ;
0111 
0112     }
0113 }
0114 
0115 
0116 void test_LowerIndex()
0117 {
0118     const char* lower = "abcdefghijklmnopqrstuvwxyz" ; 
0119     for(unsigned i=0 ; i < strlen(lower) ; i++)
0120     {
0121         char c = lower[i] ; 
0122         int li = SASCII::LowerIndex(c) ; 
0123         std::cout 
0124             << " i: " << std::setw(2) << i 
0125             << " c: " << std::setw(2) << c 
0126             << " li: " << std::setw(2) << li
0127             << std::endl
0128             ;
0129 
0130     }
0131 }
0132 
0133 
0134 
0135 void test_ToUpper_ToLower()
0136 {
0137     std::vector<std::string> strs = {
0138            "fatal", "error", "warn", "info", "debug", "verb", "none" ,
0139            "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "VERB", "NONE" 
0140          } ; 
0141     for(unsigned i=0 ; i < strs.size() ; i++)
0142     {
0143         const char* str = strs[i].c_str() ; 
0144         std::cout 
0145            << " str " << std::setw(20) << str 
0146            << " SASCII::ToUpper(str) " << std::setw(20) << SASCII::ToUpper(str) 
0147            << " SASCII::ToLower(str) " << std::setw(20) << SASCII::ToLower(str) 
0148            << std::endl 
0149            ; 
0150     }
0151 }
0152 
0153 
0154 int main(int argc, char** argv )
0155 {
0156    /*
0157    test_dump(); 
0158    test_UpperIndex();  
0159    test_LowerIndex();  
0160    */
0161    test_ToUpper_ToLower(); 
0162 
0163    return 0 ; 
0164 }
0165 
0166 
0167 /*
0168 
0169   "ADTableStainlessSteel": "AS",
0170         "Acrylic": "Ac",
0171         "Air": "Ai",
0172         "Aluminium": "Al",
0173         "Bialkali": "Bk",
0174         "DeadWater": "Dw",
0175         "ESR": "ES",
0176         "Foam": "Fo",
0177         "GdDopedLS": "Gd",
0178         "IwsWater": "Iw",
0179         "LiquidScintillator": "LS",
0180         "MineralOil": "MO",
0181         "Nitrogen": "Ni",
0182         "NitrogenGas": "NG",
0183         "Nylon": "Ny",
0184         "OwsWater": "Ow",
0185         "PPE": "PP",
0186         "PVC": "PV",
0187         "Pyrex": "Py",
0188         "Rock": "Rk",
0189         "StainlessSteel": "SS",
0190         "Tyvek": "Ty",
0191         "UnstStainlessSteel": "US",
0192         "Vacuum": "Vm",
0193         "OpaqueVacuum": "OV",
0194         "Water": "Wt",
0195         "GlassSchottF2": "F2"
0196 
0197 
0198 */
0199