File indexing completed on 2026-04-09 07:49:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
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
0158
0159
0160
0161 test_ToUpper_ToLower();
0162
0163 return 0 ;
0164 }
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199