- Timestamp:
- Jun 28, 2010, 12:19:11 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lang/tcl/tests/units.test
r1740 r1782 1048 1048 } {0 sK 0 time*temperature} 1049 1049 1050 #-------------------------------------------------------------------- 1051 # Allow isspace whitespace in Rappture::Units 1052 #-------------------------------------------------------------------- 1053 1054 test space-7.0.0.1 {check for spaces before value unit string} { 1055 list [catch {Rappture::Units::Search::for " 300K"} msg] $msg 1056 } {0 K} 1057 1058 test space-7.0.0.2 {check for spaces after value unit string} { 1059 list [catch {Rappture::Units::Search::for "300K "} msg] $msg 1060 } {0 K} 1061 1062 test space-7.0.0.3 {check for spaces before and after value unit string} { 1063 list [catch {Rappture::Units::Search::for " 300K "} msg] $msg 1064 } {0 K} 1065 1066 test space-7.0.0.4 {check for spaces between value and unit string} { 1067 list [catch {Rappture::Units::Search::for " 300 K "} msg] $msg 1068 } {0 K} 1069 1070 test space-7.0.0.5 {check for spaces between value and single unit string} { 1071 list [catch {Rappture::Units::Search::for "300 K"} msg] $msg 1072 } {0 K} 1073 1074 test space-7.0.0.6 {check for spaces between value and multiple unit string} { 1075 list [catch {Rappture::Units::Search::for "300 Kft"} msg] $msg 1076 } {0 Kft} 1077 1078 test space-7.0.0.7 {check for spaces around and between value and multiple unit string} { 1079 list [catch {Rappture::Units::Search::for " 300 Kft "} msg] $msg 1080 } {0 Kft} 1081 1082 test space-7.0.0.8 {check for spaces between multiple unit string} { 1083 list [catch {Rappture::Units::Search::for "300 K ft"} msg] $msg 1084 } {0 Kft} 1085 1086 test space-7.0.0.9 {check for spaces around and between multiple unit string} { 1087 list [catch {Rappture::Units::Search::for " 300 K ft "} msg] $msg 1088 } {0 Kft} 1089 1090 test space-7.0.0.10 {check for spaces between multiple unit string with division} { 1091 list [catch {Rappture::Units::Search::for "300 K / ft"} msg] $msg 1092 } {0 K/ft} 1093 1094 test space-7.0.0.11 {check for spaces between multiple unit string with multiplication} { 1095 list [catch {Rappture::Units::Search::for "300 K * ft"} msg] $msg 1096 } {0 Kft} 1097 1098 test space-7.0.1.1 {check for tabs before value unit string} { 1099 list [catch {Rappture::Units::Search::for "\t300K"} msg] $msg 1100 } {0 K} 1101 1102 test space-7.0.1.2 {check for tabs after value unit string} { 1103 list [catch {Rappture::Units::Search::for "300K\t"} msg] $msg 1104 } {0 K} 1105 1106 test space-7.0.1.3 {check for tabs before and after value unit string} { 1107 list [catch {Rappture::Units::Search::for "\t300K\t"} msg] $msg 1108 } {0 K} 1109 1110 test space-7.0.1.4 {check for tabs between value and unit string} { 1111 list [catch {Rappture::Units::Search::for "\t300\tK\t"} msg] $msg 1112 } {0 K} 1113 1114 test space-7.0.1.5 {check for tabs between value and single unit string} { 1115 list [catch {Rappture::Units::Search::for "300\tK"} msg] $msg 1116 } {0 K} 1117 1118 test space-7.0.1.6 {check for tabs between value and multiple unit string} { 1119 list [catch {Rappture::Units::Search::for "300\tKft"} msg] $msg 1120 } {0 Kft} 1121 1122 test space-7.0.1.7 {check for tabs around and between value and multiple unit string} { 1123 list [catch {Rappture::Units::Search::for "\t300\tKft\t"} msg] $msg 1124 } {0 Kft} 1125 1126 test space-7.0.1.8 {check for tabs between multiple unit string} { 1127 list [catch {Rappture::Units::Search::for "300\tK\tft"} msg] $msg 1128 } {0 Kft} 1129 1130 test space-7.0.1.9 {check for tabs around and between multiple unit string} { 1131 list [catch {Rappture::Units::Search::for "\t300\tK\tft\t"} msg] $msg 1132 } {0 Kft} 1133 1134 test space-7.0.1.10 {check for tabs between multiple unit string with division} { 1135 list [catch {Rappture::Units::Search::for "300\tK\t/\tft"} msg] $msg 1136 } {0 K/ft} 1137 1138 test space-7.0.1.11 {check for tabs between multiple unit string with multiplication} { 1139 list [catch {Rappture::Units::Search::for "300\tK\t*\tft"} msg] $msg 1140 } {0 Kft} 1141 1142 test space-7.0.2.1 {check for newlines before value unit string} { 1143 list [catch {Rappture::Units::Search::for "\n300K"} msg] $msg 1144 } {0 K} 1145 1146 test space-7.0.2.2 {check for newlines after value unit string} { 1147 list [catch {Rappture::Units::Search::for "300K\n"} msg] $msg 1148 } {0 K} 1149 1150 test space-7.0.2.3 {check for newlines before and after value unit string} { 1151 list [catch {Rappture::Units::Search::for "\n300K\n"} msg] $msg 1152 } {0 K} 1153 1154 test space-7.0.2.4 {check for newlines between value and unit string} { 1155 list [catch {Rappture::Units::Search::for "\n300\nK\n"} msg] $msg 1156 } {0 K} 1157 1158 test space-7.0.2.5 {check for newlines between value and single unit string} { 1159 list [catch {Rappture::Units::Search::for "300\nK"} msg] $msg 1160 } {0 K} 1161 1162 test space-7.0.2.6 {check for newlines between value and multiple unit string} { 1163 list [catch {Rappture::Units::Search::for "300\nKft"} msg] $msg 1164 } {0 Kft} 1165 1166 test space-7.0.2.7 {check for newlines around and between value and multiple unit string} { 1167 list [catch {Rappture::Units::Search::for "\n300\nKft\n"} msg] $msg 1168 } {0 Kft} 1169 1170 test space-7.0.2.8 {check for newlines between multiple unit string} { 1171 list [catch {Rappture::Units::Search::for "300\nK\nft"} msg] $msg 1172 } {0 Kft} 1173 1174 test space-7.0.2.9 {check for newlines around and between multiple unit string} { 1175 list [catch {Rappture::Units::Search::for "\n300\nK\nft\n"} msg] $msg 1176 } {0 Kft} 1177 1178 test space-7.0.2.10 {check for newlines between multiple unit string with division} { 1179 list [catch {Rappture::Units::Search::for "300\nK\n/\nft"} msg] $msg 1180 } {0 K/ft} 1181 1182 test space-7.0.2.11 {check for newlines between multiple unit string with multiplication} { 1183 list [catch {Rappture::Units::Search::for "300\nK\n*\nft"} msg] $msg 1184 } {0 Kft} 1185 1186 # TODO: 1187 # add tests for space and tab, space and newline, tab and newline 1188 # add tests for bad characters &^%$#@!)(~`{}[]:;"'?><,.-_=+\ or | 1189 1050 1190 ::tcltest::cleanupTests 1051 1191 return -
trunk/src/core/RpUnits.cc
r1740 r1782 1025 1025 const RpUnits* prefix = NULL; 1026 1026 1027 1028 1027 while ( !myInUnits.empty() ) { 1029 1028 … … 1044 1043 // type = myInUnits[last] + type; 1045 1044 // ignore * because we assume everything is multiplied together 1045 myInUnits.erase(last); 1046 continue; 1047 } 1048 1049 // ignore whitespace characters 1050 if (isspace(myInUnits[last])) { 1051 // ignore whitespace characters, they represent multiplication 1046 1052 myInUnits.erase(last); 1047 1053 continue; … … 3288 3294 retVal = 1; 3289 3295 } 3290 else {3291 }3292 3296 3293 3297 outUnits = std::string(endptr);
Note: See TracChangeset
for help on using the changeset viewer.