51 std::ostream&
operator<<(std::ostream& s,
const std::vector<std::string>& v)
54 std::copy(v.begin(), v.end(),
55 std::ostream_iterator<std::string>(s,
", "));
64 { 0x00, 0x10, 0x30, 0x33, 0x30, 0x31, 0x30, 0x35,
65 0x3A, 0x65, 0x70, 0x68, 0x20, 0x3A, 0x30, 0x3A,
66 0x35, 0x32, 0x36, 0x34, 0x30, 0x2E, 0x33, 0x33,
67 0x33, 0x34, 0x30, 0x32, 0x37, 0x37, 0x37, 0x37,
68 0x37, 0x37, 0x37, 0x38, 0x41, 0x20, 0x52, 0x61,
69 0x6e, 0x64, 0x6F, 0x6D, 0x20, 0x4D, 0x65, 0x73,
70 0x73, 0x61, 0x67, 0x65, 0x32, 0x35, 0x39, 0x32,
71 0x35, 0x39, 0x32, 0x34, 0x20, 0x32, 0x20, 0x35,
72 0x32, 0x36, 0x34, 0x30, 0x2E, 0x33, 0x33, 0x38,
73 0x38, 0x33, 0x36, 0x33, 0x34, 0x32, 0x35, 0x39,
74 0x32, 0x35, 0x39, 0x33, 0x20, 0x7F, 0x20, 0x38,
75 0x35, 0x34, 0x31, 0x32, 0x20, 0x31, 0x20, 0x31,
76 0x20, 0x30, 0x20, 0x31, 0x20, 0x31, 0x20, 0x34,
77 0x20, 0x32, 0x20, 0x34, 0x20, 0x30, 0x20, 0x30,
78 0x20, 0x33, 0x20, 0x31, 0x31, 0x39, 0x39, 0x20,
79 0x32, 0x32, 0x63, 0x30, 0x61, 0x66, 0x30, 0x33,
80 0x20, 0x31, 0x37, 0x37, 0x30, 0x32, 0x39, 0x65,
81 0x34, 0x20, 0x61, 0x66, 0x34, 0x30, 0x30, 0x31,
82 0x66, 0x20, 0x65, 0x36, 0x31, 0x62, 0x35, 0x38,
83 0x61, 0x20, 0x35, 0x35, 0x66, 0x33, 0x37, 0x35,
84 0x30, 0x20, 0x34, 0x63, 0x63, 0x61, 0x38, 0x38,
85 0x37, 0x20, 0x31, 0x31, 0x35, 0x64, 0x37, 0x63,
86 0x66, 0x63, 0x20, 0x33, 0x61, 0x64, 0x32, 0x30,
87 0x34, 0x38, 0x61, 0x20, 0x63, 0x65, 0x61, 0x20,
88 0x33, 0x36, 0x32, 0x63, 0x34, 0x38, 0x20, 0x31,
89 0x31, 0x39, 0x39, 0x20, 0x32, 0x32, 0x63, 0x30,
90 0x61, 0x66, 0x30, 0x33, 0x20, 0x31, 0x37, 0x37,
91 0x30, 0x34, 0x61, 0x37, 0x34, 0x20, 0x33, 0x61,
92 0x63, 0x34, 0x36, 0x36, 0x63, 0x31, 0x20, 0x62,
93 0x64, 0x30, 0x63, 0x36, 0x64, 0x63, 0x20, 0x33,
94 0x39, 0x31, 0x62, 0x33, 0x37, 0x38, 0x33, 0x20,
95 0x33, 0x65, 0x30, 0x34, 0x30 };
101 { 0x61, 0x66, 0x30, 0x33, 0x30, 0x31, 0x30, 0x35,
102 0x3A, 0x65, 0x70, 0x68, 0x20, 0x3A, 0x30, 0x3A,
103 0x35, 0x32, 0x36, 0x34, 0x30, 0x2E, 0x33, 0x33,
104 0x33, 0x34, 0x30, 0x32, 0x37, 0x37, 0x37, 0x37,
105 0x37, 0x37, 0x37, 0x38, 0x41, 0x20, 0x52, 0x61,
106 0x6e, 0x64, 0x6F, 0x6D, 0x20, 0x4D, 0x65, 0x73,
107 0x73, 0x61, 0x67, 0x65, 0x32, 0x35, 0x39, 0x32,
108 0x35, 0x39, 0x32, 0x34, 0x20, 0x32, 0x20, 0x35,
109 0x32, 0x36, 0x34, 0x30, 0x2E, 0x33, 0x33, 0x38,
110 0x38, 0x33, 0x36, 0x33, 0x34, 0x32, 0x35, 0x39,
111 0x32, 0x35, 0x39, 0x33, 0x20, 0x32, 0x20, 0x38,
112 0x35, 0x34, 0x31, 0x32, 0x20, 0x31, 0x20, 0x31,
113 0x20, 0x30, 0x20, 0x31, 0x20, 0x31, 0x20, 0x34,
114 0x20, 0x32, 0x20, 0x34, 0x20, 0x30, 0x20, 0x30,
115 0x20, 0x33, 0x20, 0x31, 0x31, 0x39, 0x39, 0x20,
116 0x32, 0x32, 0x63, 0x30, 0x61, 0x66, 0x30, 0x33,
117 0x20, 0x31, 0x37, 0x37, 0x30, 0x32, 0x39, 0x65,
118 0x34, 0x20, 0x61, 0x66, 0x34, 0x30, 0x30, 0x31,
119 0x66, 0x20, 0x65, 0x36, 0x31, 0x62, 0x35, 0x38,
120 0x61, 0x20, 0x35, 0x35, 0x66, 0x33, 0x37, 0x35,
121 0x30, 0x20, 0x34, 0x63, 0x63, 0x61, 0x38, 0x38,
122 0x37, 0x20, 0x31, 0x31, 0x35, 0x64, 0x37, 0x63,
123 0x66, 0x63, 0x20, 0x33, 0x61, 0x64, 0x32, 0x30,
124 0x34, 0x38, 0x61, 0x20, 0x63, 0x65, 0x61, 0x20,
125 0x33, 0x36, 0x32, 0x63, 0x34, 0x38, 0x20, 0x31,
126 0x31, 0x39, 0x39, 0x20, 0x32, 0x32, 0x63, 0x30,
127 0x61, 0x66, 0x30, 0x33, 0x20, 0x31, 0x37, 0x37,
128 0x30, 0x34, 0x61, 0x37, 0x34, 0x20, 0x33, 0x61,
129 0x63, 0x34, 0x36, 0x36, 0x63, 0x31, 0x20, 0x62,
130 0x64, 0x30, 0x63, 0x36, 0x64, 0x63, 0x20, 0x33,
131 0x39, 0x31, 0x62, 0x33, 0x37, 0x38, 0x33, 0x20,
132 0x33, 0x65, 0x30, 0x34, 0x30 };
151 static const int BUF_SIZ = 512;
152 ifstream s(fileName.c_str());
155 char *buffer =
new char[BUF_SIZ];
158 s.read(buffer, BUF_SIZ);
159 rv += string(buffer, s.gcount());
172 TUDEF(
"StringUtils",
"Justify");
173 string baseString=
"1234567890";
175 string manipulatedString;
176 char fillerChar =
'-';
178 manipulatedString = baseString;
179 resultString = string(6, fillerChar) + baseString;
181 rightJustify(manipulatedString, manipulatedString.length() + 6,
183 TUCSM(
"rightJustify");
184 TUASSERTE(std::string, resultString, manipulatedString);
186 manipulatedString = baseString;
187 resultString = baseString + string(6, fillerChar);
189 leftJustify(manipulatedString, manipulatedString.length()+6, fillerChar);
190 TUCSM(
"leftJustify");
191 TUASSERTE(std::string, resultString, manipulatedString);
193 manipulatedString = baseString;
194 resultString = string(3, fillerChar) + baseString +
195 string(3, fillerChar);
197 center(manipulatedString, manipulatedString.length()+6, fillerChar);
199 TUASSERTE(std::string, resultString, manipulatedString);
214 TUDEF(
"StringUtils",
"stripLeading");
215 string baseString=
"---1234567890---";
217 string manipulatedString;
218 char charToBeRemoved =
'-';
219 string stringToBeRemoved =
"--";
221 manipulatedString = baseString;
222 resultString = baseString.substr(1,string::npos);
224 manipulatedString =
stripLeading(manipulatedString, charToBeRemoved, 1);
225 TUASSERTE(std::string, resultString, manipulatedString);
227 manipulatedString = baseString;
228 resultString = baseString.substr(2,string::npos);
230 manipulatedString =
stripLeading(manipulatedString, stringToBeRemoved,
232 TUASSERTE(std::string, resultString, manipulatedString);
234 manipulatedString = baseString;
235 resultString = baseString.substr(3,string::npos);
237 manipulatedString =
stripLeading(manipulatedString, charToBeRemoved);
238 TUASSERTE(std::string, resultString, manipulatedString);
240 manipulatedString = baseString;
241 resultString = baseString.substr(2,string::npos);
243 manipulatedString =
stripLeading(manipulatedString, stringToBeRemoved);
244 TUASSERTE(std::string, resultString, manipulatedString);
258 TUDEF(
"StringUtils",
"stripTrailing");
259 string baseString=
"---1234567890---";
261 string manipulatedString;
262 char charToBeRemoved =
'-';
263 string stringToBeRemoved =
"--";
265 manipulatedString = baseString;
266 resultString = baseString.substr(0, baseString.length()-1);
268 manipulatedString =
stripTrailing(manipulatedString, charToBeRemoved, 1);
269 TUASSERTE(std::string, resultString, manipulatedString);
271 manipulatedString = baseString;
272 resultString = baseString.substr(0, baseString.length()-2);
274 manipulatedString =
stripTrailing(manipulatedString, stringToBeRemoved,
276 TUASSERTE(std::string, resultString, manipulatedString);
278 manipulatedString = baseString;
279 resultString = baseString.substr(0, baseString.length()-3);
281 manipulatedString =
stripTrailing(manipulatedString, charToBeRemoved);
282 TUASSERTE(std::string, resultString, manipulatedString);
284 manipulatedString = baseString;
285 resultString = baseString.substr(0, baseString.length()-2);
287 manipulatedString =
stripTrailing(manipulatedString, stringToBeRemoved);
288 TUASSERTE(std::string, resultString, manipulatedString);
302 TUDEF(
"StringUtils",
"strip");
303 string baseString=
"---1234567890---";
305 string manipulatedString;
306 char charToBeRemoved =
'-';
307 string stringToBeRemoved =
"--";
309 manipulatedString = baseString;
310 resultString = baseString.substr(1,baseString.length()-2);
312 manipulatedString =
strip(manipulatedString, charToBeRemoved, 1);
313 TUASSERTE(std::string, resultString, manipulatedString);
315 manipulatedString = baseString;
316 resultString = baseString.substr(2,baseString.length()-4);
318 manipulatedString =
strip(manipulatedString, stringToBeRemoved, 1);
319 TUASSERTE(std::string, resultString, manipulatedString);
321 manipulatedString = baseString;
322 resultString = baseString.substr(3, baseString.length()-6);
324 manipulatedString =
strip(manipulatedString, charToBeRemoved);
325 TUASSERTE(std::string, resultString, manipulatedString);
327 manipulatedString = baseString;
328 resultString = baseString.substr(2, baseString.length()-4);
330 manipulatedString =
strip(manipulatedString, stringToBeRemoved);
331 TUASSERTE(std::string, resultString, manipulatedString);
344 TUDEF(
"StringUtils",
"strip");
346 string baseString =
"Hello World! I am the Translation test String!";
348 string manipulatedString;
350 string translateFrom =
"aeoWTS!";
352 string translateTo1 =
"@30M7Q1";
354 string expResult1 =
"H3ll0 M0rld1 I @m th3 7r@nsl@ti0n t3st Qtring1";
356 string translateTo2 =
"@30M7";
358 string expResult2 =
"H3ll0 M0rld I @m th3 7r@nsl@ti0n t3st tring ";
360 string translateTo3 =
"aeoWTS!";
362 string expResult3 =
"Hello World! I am the Translation test String!";
364 manipulatedString =
translate(baseString, translateFrom, translateTo1);
365 TUASSERTE(std::string, expResult1, manipulatedString);
367 manipulatedString =
translate(baseString, translateFrom, translateTo2);
368 TUASSERTE(std::string, expResult2, manipulatedString);
370 manipulatedString =
translate(baseString, translateFrom, translateTo3);
371 TUASSERTE(std::string, expResult3, manipulatedString);
384 TUDEF(
"StringUtils",
"asInt");
386 string baseString =
"12345.67890";
388 int resultingInt, comparisonInt = 12345;
390 double resultingDouble, comparisonDouble = 12345.67890;
392 float resultingFloat, comparisonFloat = 12345.67890f;
394 long double resultingLongDouble, comparisonLongDouble = 12345.67890L;
396 resultingInt =
asInt(baseString);
397 TUASSERTE(
int, comparisonInt, resultingInt);
400 resultingDouble =
asDouble(baseString);
401 TUASSERTE(
double, comparisonDouble, resultingDouble);
404 resultingFloat =
asFloat(baseString);
405 TUASSERTE(
float, comparisonFloat, resultingFloat);
407 TUCSM(
"asLongDouble");
409 TUASSERTE(
long double, comparisonLongDouble, resultingLongDouble);
426 TUDEF(
"StringUtils",
"asString");
427 string convertedString;
428 int sampleInt = 1234567890;
429 double sampleDouble = 12345.67890;
430 float sampleFloat = 12345.7f;
432 long double sampleLongDouble = 12345.67890L;
434 convertedString =
asString(sampleInt);
437 convertedString =
asString(sampleDouble);
440 convertedString =
asString(sampleFloat);
443 convertedString =
asString(sampleLongDouble);
457 TUDEF(
"StringUtils",
"x2d");
459 string initialHexString =
"0x100 foo";
461 string correctConvertedHexString =
"256 foo";
463 string initialDecimalString =
"100 bar";
465 string correctConvertedDecimalString =
"64 bar";
467 string manipulatedResult;
469 manipulatedResult =
x2d(initialHexString);
470 TUASSERTE(std::string, correctConvertedHexString, initialHexString);
473 manipulatedResult =
d2x(initialDecimalString);
474 TUASSERTE(std::string, correctConvertedDecimalString,
475 initialDecimalString);
491 TUDEF(
"StringUtils",
"replaceAll");
492 string baseString =
"010101000111010";
493 string replaced1s =
"0-0-0-000---0-0";
494 string replaced1withABC =
"0ABC0ABC0ABC000ABCABCABC0ABC0";
495 string replaced1with123 =
"01230123012300012312312301230";
496 string manipulatedString;
498 manipulatedString = baseString;
499 manipulatedString =
replaceAll(manipulatedString,
string(
"1"),
501 TUASSERTE(std::string, replaced1s, manipulatedString);
503 manipulatedString = baseString;
504 manipulatedString =
replaceAll(manipulatedString,
string(
"1"),
506 TUASSERTE(std::string, replaced1withABC, manipulatedString);
508 manipulatedString = baseString;
509 manipulatedString =
replaceAll(manipulatedString,
string(
"1"),
511 TUASSERTE(std::string, replaced1with123, manipulatedString);
524 TUDEF(
"StringUtils",
"firstWord");
526 string originalString =
" The Quick Brown Fox Jumps Over"
529 string firstWordInString =
"The";
531 int numberOfWords = 9;
534 string fifthWordInString =
"Jumps";
536 string removedFourthFifthWords =
" The Quick Brown Over The"
540 string removedFirstWord =
"Quick Brown Over The Lazy "
544 string removedSixthWord =
"Quick Brown Over The Lazy";
547 string allWordsFromFourthOn =
"The Lazy";
552 TUASSERTE(std::string,
"", resultString);
554 resultString =
firstWord(originalString);
555 TUASSERTE(std::string, firstWordInString, resultString);
561 resultInt =
numWords(originalString);
562 TUASSERTE(
int, numberOfWords, resultInt);
565 resultString =
word(
"",2);
566 TUASSERTE(std::string,
"", resultString);
568 resultString =
word(originalString,4);
569 TUASSERTE(std::string, fifthWordInString, resultString);
571 resultString =
word(originalString,10);
572 TUASSERTE(std::string,
"", resultString);
576 TUCSM(
"removeWords");
579 TUASSERTE(std::string,
"", resultString);
582 TUASSERTE(std::string, removedFourthFifthWords, originalString);
583 TUASSERTE(std::string, removedFourthFifthWords, resultString);
585 TUCSM(
"stripFirstWord");
588 TUASSERTE(std::string,
"", resultString);
591 TUASSERTE(std::string, removedFirstWord, originalString);
592 TUASSERTE(std::string, firstWordInString, resultString);
594 TUCSM(
"removeWords");
597 TUASSERTE(std::string,
"", resultString);
602 std::string oneWord(
"foo");
608 TUASSERTE(std::string, removedSixthWord, originalString);
609 TUASSERTE(std::string, removedSixthWord, resultString);
611 std::string removeAllOfMe(originalString);
613 TUASSERTE(std::string,
"", removeAllOfMe);
614 TUASSERTE(std::string,
"", resultString);
619 resultString =
words(
"", 2);
620 TUASSERTE(std::string, std::string(), resultString);
622 resultString =
words(originalString, 3);
623 TUASSERTE(std::string, allWordsFromFourthOn, resultString);
625 resultString =
words(originalString, 10);
626 TUASSERTE(std::string, std::string(), resultString);
644 TUDEF(
"StringUtils",
"isLike");
646 string originalString =
" The Quick Brown Fox Jumps Over"
651 string testedRegularExpression1 =
"Br.*Over.*";
653 string testedRegularExpression2 =
"Br.Over.*";
657 string correctResult =
"Brown Fox Jumps Over The Lazy"
660 resultInt =
isLike(originalString, testedRegularExpression1);
663 resultInt =
isLike(originalString, testedRegularExpression2);
667 resultString =
matches(originalString, testedRegularExpression1);
668 TUASSERTE(std::string, correctResult, resultString);
681 TUDEF(
"StringUtils",
"prettyPrint");
682 string originalString(
"This is a very long sentence that will get cut"
683 " up into lines with a maximum length of 40"
684 " characters, each line indented by a few"
686 string prettyPrintThis = originalString;
687 string prettyPrinted =
" This is a very long sentence that\n"
688 " will get cut up into lines with a\n"
689 " maximum length of 40 characters,\n"
690 " each line indented by a few spaces.\n";
693 TUASSERTE(std::string, prettyPrinted, prettyPrintThis);
695 prettyPrintThis =
"ThisXtestsXprintingXwithXaXwordXdelimiterXotherXthan"
696 "XspaceXasXwellXasXlineXdelimetersXotherXthanXnewline";
697 prettyPrinted =
"mehhhhhhhhXThisXtestsXprintingXwithXaZZZZcruddycrudcrud"
698 "XwordXdelimiterXotherZZZZcruddycrudcrudXthanXspaceXasXwellXasZZZZ"
699 "cruddycrudcrudXlineXdelimetersXotherZZZZcruddycrudcrudXthanXnewline"
701 prettyPrint(prettyPrintThis,
"ZZZZ",
"cruddycrudcrud",
"mehhhhhhhh", 37,
703 TUASSERTE(std::string, prettyPrinted, prettyPrintThis);
707 originalString =
"Bit-field: inject errors"
708 "\nbit 0 - corrupt lengths"
709 "\nbit 1 - corrupt addressing"
710 "\nbit 2 - corrupt checksum"
711 "\nbit 3 - corrupt `format'";
712 prettyPrintThis = originalString;
713 prettyPrinted =
" -j, --error-inj=NUM Bit-field: inject errors\n"
714 " bit 0 - corrupt lengths\n"
715 " bit 1 - corrupt addressing\n"
716 " bit 2 - corrupt checksum\n"
717 " bit 3 - corrupt `format'\n";
719 " -j, --error-inj=NUM ", 80);
720 TUASSERTE(std::string, prettyPrinted, prettyPrintThis);
734 TUDEF(
"StringUtils",
"splitWithQuotes");
736 std::string originalString(
"String with no quotes");
737 std::vector<std::string> expectedResult;
738 expectedResult.push_back(
"String");
739 expectedResult.push_back(
"with");
740 expectedResult.push_back(
"no");
741 expectedResult.push_back(
"quotes");
742 std::vector<std::string> observedResult =
744 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
748 expectedResult.clear();
750 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
753 originalString =
" ";
754 expectedResult.clear();
755 expectedResult.push_back(
"");
756 expectedResult.push_back(
"");
758 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
761 originalString = std::string(
"String with \"double quoted values\"");
762 expectedResult.clear();
763 expectedResult.push_back(
"String");
764 expectedResult.push_back(
"with");
765 expectedResult.push_back(
"double quoted values");
767 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
770 originalString= std::string(
"String with \'single quoted values\'");
771 expectedResult.clear();
772 expectedResult.push_back(
"String");
773 expectedResult.push_back(
"with");
774 expectedResult.push_back(
"single quoted values");
776 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
779 originalString= std::string(
"\"First words\" quoted");
780 expectedResult.clear();
781 expectedResult.push_back(
"First words");
782 expectedResult.push_back(
"quoted");
784 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
787 originalString= std::string(
"\"Back to\" \"back quotes\"");
788 expectedResult.clear();
789 expectedResult.push_back(
"Back to");
790 expectedResult.push_back(
"back quotes");
792 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
796 std::string(
"Zan.35(KB04-KB01), +90 7 7.73619,,,,-1.52405,no,,,");
797 expectedResult.clear();
798 expectedResult.push_back(
"Zan.35(KB04-KB01)");
799 expectedResult.push_back(
"+90 7 7.73619");
800 expectedResult.push_back(
"");
801 expectedResult.push_back(
"");
802 expectedResult.push_back(
"");
803 expectedResult.push_back(
"-1.52405");
804 expectedResult.push_back(
"no");
805 expectedResult.push_back(
"");
806 expectedResult.push_back(
"");
807 expectedResult.push_back(
"");
809 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
821 TUDEF(
"StringUtils",
"splitWithDoubleQuotes");
823 std::string originalString(
"String with no quotes");
824 std::vector<std::string> expectedResult;
825 expectedResult.push_back(
"String");
826 expectedResult.push_back(
"with");
827 expectedResult.push_back(
"no");
828 expectedResult.push_back(
"quotes");
829 std::vector<std::string> observedResult =
831 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
835 expectedResult.clear();
837 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
840 originalString =
" ";
841 expectedResult.clear();
842 expectedResult.push_back(
"");
843 expectedResult.push_back(
"");
845 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
848 originalString = std::string(
"String with \"double quoted values\"");
849 expectedResult.clear();
850 expectedResult.push_back(
"String");
851 expectedResult.push_back(
"with");
852 expectedResult.push_back(
"double quoted values");
854 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
857 originalString= std::string(
"String with \'single quoted values\'");
858 expectedResult.clear();
859 expectedResult.push_back(
"String");
860 expectedResult.push_back(
"with");
861 expectedResult.push_back(
"\'single");
862 expectedResult.push_back(
"quoted");
863 expectedResult.push_back(
"values\'");
865 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
868 originalString= std::string(
"\"First words\" quoted");
869 expectedResult.clear();
870 expectedResult.push_back(
"First words");
871 expectedResult.push_back(
"quoted");
873 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
876 originalString= std::string(
"\"Back to\" \"back quotes\"");
877 expectedResult.clear();
878 expectedResult.push_back(
"Back to");
879 expectedResult.push_back(
"back quotes");
881 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
885 std::string(
"Zan.35(KB04-KB01), +90 7 7.73619,,,,-1.52405,no,,,");
886 expectedResult.clear();
887 expectedResult.push_back(
"Zan.35(KB04-KB01)");
888 expectedResult.push_back(
"+90 7 7.73619");
889 expectedResult.push_back(
"");
890 expectedResult.push_back(
"");
891 expectedResult.push_back(
"");
892 expectedResult.push_back(
"-1.52405");
893 expectedResult.push_back(
"no");
894 expectedResult.push_back(
"");
895 expectedResult.push_back(
"");
896 expectedResult.push_back(
"");
898 TUASSERTE(std::vector<std::string>, expectedResult, observedResult);
918 TUDEF(
"StringUtils",
"hexDumpData");
919 stringstream hexDumpStream;
920 string correctHexDump;
921 stringstream configHexDumpStream;
922 string correctConfigHexDump;
923 string correctPrintableMessage;
924 stringstream printableMessageStream;
927 string refPath = gnsstk::getPathData() +
928 gnsstk::getFileSep() +
930 gnsstk::getFileSep() +
932 correctHexDump = getFileContents(refPath +
"hexDump.exp");
935 correctConfigHexDump = getFileContents(refPath +
"configHexDump.exp");
940 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
943 HexDumpDataConfig hdcfg(
true,
true,
true, 8, 2, 2, 1, 0, 0, 16,
true,
945 hexDumpData(configHexDumpStream, hexDumpString, 6, hdcfg);
946 TUCSM(
"HexDumpDataConfig");
947 TUASSERTE(std::string, correctConfigHexDump, configHexDumpStream.str());
950 correctPrintableMessage = getFileContents(refPath +
951 "printableMessage.exp");
952 printableMessageStream <<
printable(hexDumpString) ;
954 TUASSERTE(std::string, correctPrintableMessage,
955 printableMessageStream.str());
969 TUDEF(
"StringUtils",
"hexDumpData");
970 stringstream hexDumpStream;
971 string correctHexDump;
972 stringstream configHexDumpStream;
973 string correctConfigHexDump;
974 string correctPrintableMessage;
975 stringstream printableMessageStream;
978 string refPath = gnsstk::getPathData() +
979 gnsstk::getFileSep() +
981 gnsstk::getFileSep() +
983 correctHexDump = getFileContents(refPath +
"hexDump.exp");
986 correctConfigHexDump = getFileContents(refPath +
"configHexDump.exp");
991 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
994 HexDumpDataConfig hdcfg(
true,
true,
true, 8, 2, 2, 1, 0, 0, 16,
true,
996 hexDumpData(configHexDumpStream, hexDumpString, 6, hdcfg);
997 TUCSM(
"HexDumpDataConfig");
998 TUASSERTE(std::string, correctConfigHexDump, configHexDumpStream.str());
1001 correctPrintableMessage = getFileContents(refPath +
1002 "printableMessage.exp");
1003 printableMessageStream <<
printable(hexDumpString) ;
1005 TUASSERTE(std::string, correctPrintableMessage,
1006 printableMessageStream.str());
1018 TUDEF(
"StringUtils",
"hexDumpData");
1019 stringstream hexDumpStream;
1020 string correctHexDump;
1023 string refPath = gnsstk::getPathData() +
1024 gnsstk::getFileSep() +
1026 gnsstk::getFileSep() +
1027 "hexDumpDataStreamFlagTest_";
1029 correctHexDump = getFileContents(refPath +
"hexDump.exp");
1031 hexDumpStream << std::left << setw(99) << setfill(
'Z') << boolalpha
1032 << showbase << oct << scientific << showpos << uppercase;
1036 hexDumpStream <<
"foo" <<
" " <<
true <<
" " <<
false <<
" " << 12 <<
" "
1037 << -1.23e12 <<
" " << hex << 0xdeadbeef << dec << endl;
1038 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1049 TUDEF(
"StringUtils",
"hexDumpData");
1050 stringstream hexDumpStream;
1051 string correctHexDump;
1052 string hexDumpString;
1055 string refPath = gnsstk::getPathData() +
1056 gnsstk::getFileSep() +
1058 gnsstk::getFileSep() +
1059 "hexDumpDataConfigTest_";
1062 HexDumpDataConfig cfg1(
false,
true,
false, 4, 1, 1, 1, 8, 2, 16,
true,
1064 correctHexDump = getFileContents(refPath +
"hexDump_1.exp");
1067 hexDumpData(hexDumpStream, hexDumpString, 0, cfg1);
1068 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1070 hexDumpStream.str(
"");
1073 HexDumpDataConfig cfg2(
false,
true,
false, 4, 1, 1, 1, 8, 2, 16,
false,
1075 correctHexDump = getFileContents(refPath +
"hexDump_2.exp");
1078 hexDumpData(hexDumpStream, hexDumpString, 0, cfg2);
1079 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1081 hexDumpStream.str(
"");
1084 HexDumpDataConfig cfg3(
false,
true,
false, 4, 1, 1, 1, 0, 2, 16,
false,
1086 correctHexDump = getFileContents(refPath +
"hexDump_3.exp");
1089 hexDumpData(hexDumpStream, hexDumpString, 0, cfg3);
1090 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1092 hexDumpStream.str(
"");
1095 HexDumpDataConfig cfg4(
false,
true,
false, 4, 1, 1, 1, 0, 2, 8,
false,
1097 correctHexDump = getFileContents(refPath +
"hexDump_4.exp");
1100 hexDumpData(hexDumpStream, hexDumpString, 0, cfg4);
1101 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1103 hexDumpStream.str(
"");
1106 HexDumpDataConfig cfg5(
false,
true,
false, 4, 1, 1, 1, 0, 2, 8,
false,
1108 correctHexDump = getFileContents(refPath +
"hexDump_5.exp");
1111 hexDumpData(hexDumpStream, hexDumpString, 0, cfg5);
1112 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1114 hexDumpStream.str(
"");
1118 16,
true,
't',
"FOO",
true,
true,
"",
"");
1119 correctHexDump = getFileContents(refPath +
"hexDump_6.exp");
1122 hexDumpData(hexDumpStream, hexDumpString, 0, cfg6);
1123 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1125 hexDumpStream.str(
"");
1130 HexDumpDataConfig cfg7(
false,
false,
false, 4,
"", 1,
", ", 0,
"zz",
1131 8,
false,
't',
"FOO",
true,
true,
",",
"");
1132 correctHexDump = getFileContents(refPath +
"hexDump_7.exp");
1135 hexDumpData(hexDumpStream, hexDumpString, 0, cfg7);
1136 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1138 hexDumpStream.str(
"");
1142 16,
true,
't',
"FOO",
true,
true,
"meep",
1143 "shiftthissuckertotherightsome");
1144 correctHexDump = getFileContents(refPath +
"hexDump_8.exp");
1147 hexDumpData(hexDumpStream, hexDumpString, 0, cfg8);
1148 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1150 hexDumpStream.str(
"");
1154 16,
true,
'`',
"_",
true,
true,
"meep",
1155 "shiftthissuckertotherightsome");
1156 correctHexDump = getFileContents(refPath +
"hexDump_9.exp");
1159 hexDumpData(hexDumpStream, hexDumpString, 0, cfg9);
1160 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1162 hexDumpStream.str(
"");
1167 16,
true,
'`',
"_",
true,
true,
"meep",
1168 "shiftthissuckertotherightsome");
1169 correctHexDump = getFileContents(refPath +
"hexDump_10.exp");
1172 hexDumpString = string(
hexDumpArray2, truesize - (truesize % 16));
1173 hexDumpData(hexDumpStream, hexDumpString, 0, cfg10);
1174 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1176 hexDumpStream.str(
"");
1179 HexDumpDataConfig cfg11(
false,
false,
false, 0,
"", 1,
", ", 0,
"", 8,
1180 false, (
char)0,
"",
true,
false,
",",
"");
1181 correctHexDump = getFileContents(refPath +
"hexDump_11.exp");
1183 unsigned char allChars[256];
1184 for (
unsigned i = 0; i < 256; i++)
1186 hexDumpString = string((
char*)allChars, 256);
1187 hexDumpData(hexDumpStream, hexDumpString, 0, cfg11);
1188 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1190 hexDumpStream.str(
"");
1195 HexDumpDataConfig cfg12(
false,
false,
false, 0,
"", 1,
", ", 0,
"",
1196 8,
true,
" /* ",
" */",
true,
false,
",",
"",
1198 correctHexDump = getFileContents(refPath +
"hexDump_12.exp");
1202 TUASSERTE(std::string, correctHexDump, hexDumpStream.str());
1204 hexDumpStream.str(
"");
1211 TUDEF(
"StringUtils",
"floatFormat");
1214 double n1 = -1.2345;
1247 TUASSERTE(
string,
"0.000000000000000e+000",
1264 unsigned errorTotal = 0;
1275 errorTotal += testClass.
wordTest();
1286 std::cout <<
"Total Failures for " << __FILE__ <<
": " << errorTotal