Directory: | ./ |
---|---|
File: | TESTS/TEST_STRING_FUNCTION/main.cpp |
Date: | 2024-11-07 16:05:26 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 153 | 153 | 100.0% |
Branches: | 647 | 655 | 98.8% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | |||
2 | /*************************************** | ||
3 | Auteur : Pierre Aubert | ||
4 | Mail : pierre.aubert@lapp.in2p3.fr | ||
5 | Licence : CeCILL-C | ||
6 | ****************************************/ | ||
7 | |||
8 | #include <iostream> | ||
9 | #include <vector> | ||
10 | #include "phoenix_assert.h" | ||
11 | #include "phoenix_check.h" | ||
12 | |||
13 | #include "string_function.h" | ||
14 | |||
15 | ///Check string lower expression | ||
16 | /** @param testName : name of the test | ||
17 | * @param strValue : string to be tested | ||
18 | * @param strReference : reference string | ||
19 | * @return true is both strings are equal, false otherwise | ||
20 | */ | ||
21 | 13 | bool checkString(const std::string & testName, const std::string & strValue, const std::string & strReference){ | |
22 | 13 | return phoenix_check(testName, strValue, strReference); | |
23 | } | ||
24 | |||
25 | ///Test the find in list string filename function | ||
26 | 1 | void testFindInListString(){ | |
27 | 1 | std::list<std::string> listStrRef; | |
28 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInListString(listStrRef, "")); |
29 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | listStrRef.push_back("one"); |
30 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInListString(listStrRef, "")); |
31 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInListString(listStrRef, "other")); |
32 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInListString(listStrRef, "one")); |
33 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | listStrRef.push_back("two"); |
34 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInListString(listStrRef, "other")); |
35 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInListString(listStrRef, "two")); |
36 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | listStrRef.push_back("three"); |
37 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInListString(listStrRef, "other")); |
38 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInListString(listStrRef, "two")); |
39 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInListString(listStrRef, "three")); |
40 | |||
41 | 1 | std::vector<std::string> vecStrRef; | |
42 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInVectorString(vecStrRef, "")); |
43 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecStrRef.push_back("one"); |
44 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInVectorString(vecStrRef, "")); |
45 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInVectorString(vecStrRef, "other")); |
46 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInVectorString(vecStrRef, "one")); |
47 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecStrRef.push_back("two"); |
48 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInVectorString(vecStrRef, "other")); |
49 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInVectorString(vecStrRef, "two")); |
50 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecStrRef.push_back("three"); |
51 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInVectorString(vecStrRef, "other")); |
52 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInVectorString(vecStrRef, "two")); |
53 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInVectorString(vecStrRef, "three")); |
54 | |||
55 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
|
1 | phoenix_assert(eraseLastCharsInStr("", "afe") == ""); |
56 | |||
57 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 29 taken 1 times.
|
1 | phoenix_assert(replaceStrInStr("", "", "") == ""); |
58 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 29 taken 1 times.
|
1 | phoenix_assert(replaceStrInStr("", "o", "") == ""); |
59 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 29 taken 1 times.
|
1 | phoenix_assert(replaceStrInStr("o", "", "") == ""); |
60 | 1 | } | |
61 | |||
62 | ///Test the string filename function | ||
63 | 1 | void testStringFunction(){ | |
64 |
1/1✓ Branch 2 taken 1 times.
|
1 | std::string testString("some string to be used"); |
65 | |||
66 |
9/9✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
✓ Branch 31 taken 1 times.
|
1 | phoenix_assert(checkString("Test replaceCharInStr", replaceCharInStr(testString, 'o', "O"), "sOme string tO be used")); |
67 |
9/9✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
✓ Branch 31 taken 1 times.
|
1 | phoenix_assert(checkString("Test replaceCharsInStr", replaceCharsInStr(testString, "ot", 'X'), "sXme sXring XX be used")); |
68 |
10/10✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 29 taken 1 times.
✓ Branch 32 taken 1 times.
✓ Branch 35 taken 1 times.
|
1 | phoenix_assert(checkString("Test replaceStrInStr", replaceStrInStr(testString, "string", "text"), "some text to be used")); |
69 | 1 | std::vector<std::string> vecStringToReplace; | |
70 |
1/1✓ Branch 1 taken 1 times.
|
1 | vecStringToReplace.push_back(testString); |
71 |
3/3✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 9 taken 1 times.
|
2 | std::vector<std::string> vecReplacedString = replaceStrInStr(vecStringToReplace, "string", "text"); |
72 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
|
1 | phoenix_assert(checkString("Test replaceStrInStr vector", vecReplacedString[0], "some text to be used")); |
73 |
9/9✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
✓ Branch 31 taken 1 times.
|
1 | phoenix_assert(checkString("Test copyStr", copyStr("Some string", 2lu, 4lu), "me s")); |
74 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
✓ Branch 27 taken 1 times.
|
1 | phoenix_assert(checkString("Test eraseCharInStr", eraseCharInStr(testString, 'o'), "sme string t be used")); |
75 |
9/9✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
✓ Branch 31 taken 1 times.
|
1 | phoenix_assert(checkString("Test eraseCharInStr", eraseCharInStr("", 'o'), "")); |
76 |
9/9✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
✓ Branch 31 taken 1 times.
|
1 | phoenix_assert(checkString("Test eraseCharsInStr", eraseCharsInStr(testString, "o"), "sme string t be used")); |
77 |
9/9✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
✓ Branch 31 taken 1 times.
|
1 | phoenix_assert(checkString("Test eraseCharsInStr", eraseCharsInStr(testString, "oxi"), "sme strng t be used")); |
78 |
10/10✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 29 taken 1 times.
✓ Branch 32 taken 1 times.
✓ Branch 35 taken 1 times.
|
1 | phoenix_assert(checkString("Test eraseCharsInStr", eraseCharsInStr("", "o"), "")); |
79 |
10/10✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 29 taken 1 times.
✓ Branch 32 taken 1 times.
✓ Branch 35 taken 1 times.
|
1 | phoenix_assert(checkString("Test replaceCharsInStr", replaceCharsInStr("", "o", 'd'), "")); |
80 |
10/10✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 29 taken 1 times.
✓ Branch 32 taken 1 times.
✓ Branch 35 taken 1 times.
|
1 | phoenix_assert(checkString("Test replaceCharsInStr", replaceCharsInStr("", "", 'd'), "")); |
81 |
10/10✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 29 taken 1 times.
✓ Branch 32 taken 1 times.
✓ Branch 35 taken 1 times.
|
1 | phoenix_assert(checkString("Test replaceCharsInStr", replaceCharsInStr("o", "", 'd'), "o")); |
82 | |||
83 | 1 | std::vector<std::string> vecStrRef; | |
84 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecStrRef.push_back("one"); |
85 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecStrRef.push_back("two"); |
86 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecStrRef.push_back("three"); |
87 | |||
88 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | std::list<std::string> listStr(cutStringList("one two three", ' ')); |
89 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | std::vector<std::string> vecStr(cutStringVector("one two three", ' ')); |
90 | |||
91 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | std::list<std::string> listSpaceStr(cutStringOnSpacesList("one two three")); |
92 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | std::vector<std::string> vecSpaceStr(cutStringOnSpacesVector("one two three")); |
93 | |||
94 | 1 | std::list<std::string>::iterator itList(listStr.begin()); | |
95 | 1 | std::list<std::string>::iterator itSpaceList(listSpaceStr.begin()); | |
96 | 1 | std::vector<std::string>::iterator itVec(vecStr.begin()); | |
97 | 1 | std::vector<std::string>::iterator itSpaceVec(vecSpaceStr.begin()); | |
98 | 1 | std::vector<std::string>::iterator itVecRef(vecStrRef.begin()); | |
99 | |||
100 |
8/12✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 3 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 3 times.
✓ Branch 21 taken 1 times.
|
4 | while(itList != listStr.end() && itVec != vecStr.end() && itVecRef != vecStrRef.end() && itSpaceList != listSpaceStr.end() && itSpaceVec != vecSpaceStr.end()){ |
101 |
6/8✓ Branch 2 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 15 taken 3 times.
✗ Branch 16 not taken.
✓ Branch 20 taken 3 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 3 times.
|
3 | phoenix_assert(*itList == *itVec && *itVec ==* itVecRef); |
102 |
6/8✓ Branch 2 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 15 taken 3 times.
✗ Branch 16 not taken.
✓ Branch 20 taken 3 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 3 times.
|
3 | phoenix_assert(*itSpaceList == *itVec && *itSpaceVec == *itVec); |
103 | |||
104 | 3 | ++itList; | |
105 | 3 | ++itVec; | |
106 | 3 | ++itVecRef; | |
107 | 3 | ++itSpaceList; | |
108 | 3 | ++itSpaceVec; | |
109 | } | ||
110 | |||
111 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInString("", 'a')); |
112 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInString("abc", 'a')); |
113 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInString("abc", 'b')); |
114 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(findInString("abc", 'c')); |
115 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(!findInString("abc", 'd')); |
116 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(!findCharsInString("", "")); |
117 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(!findCharsInString("", "a")); |
118 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(!findCharsInString("abc", "")); |
119 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(findCharsInString("abc", "a")); |
120 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(findCharsInString("abc", "b")); |
121 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(findCharsInString("abc", "c")); |
122 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(!findCharsInString("abc", "d")); |
123 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(findCharsInString("abc", "xa")); |
124 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(findCharsInString("abc", "xb")); |
125 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(findCharsInString("abc", "xc")); |
126 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(!findCharsInString("abc", "xd")); |
127 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(findCharsInString("abc", "ax")); |
128 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(findCharsInString("abc", "bx")); |
129 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(findCharsInString("abc", "cx")); |
130 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(!findCharsInString("abc", "dx")); |
131 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(countNbChar("", 'o') == 0lu); |
132 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(countNbChar("some thing to count", 'o') == 3lu); |
133 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
1 | phoenix_assert(countNbChar("some thing to count", 'w') == 0lu); |
134 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(isSameBegining("", "")); |
135 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(!isSameBegining("", "d")); |
136 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(isSameBegining("start", "start")); |
137 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(isSameBegining("start", "st")); |
138 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(!isSameBegining("st", "start")); |
139 | 1 | } | |
140 | |||
141 | ///Check the replaceVectorStrInStr function | ||
142 | /** @param inputStr : input string | ||
143 | * @param vecPattern : vector of patterns | ||
144 | * @param replace : substitution string | ||
145 | * @param strReference : expected result | ||
146 | * @return true on success, false otherwise | ||
147 | */ | ||
148 | 5 | bool checkReplaceVectorStrInStr(const std::string & inputStr, const std::vector<std::string> & vecPattern, const std::string & replace, | |
149 | const std::string & strReference) | ||
150 | { | ||
151 |
1/1✓ Branch 1 taken 5 times.
|
5 | std::string res(replaceVectorStrInStr(inputStr, vecPattern, replace)); |
152 |
2/2✓ Branch 2 taken 5 times.
✓ Branch 5 taken 5 times.
|
10 | return phoenix_check("", res, strReference); |
153 | 5 | } | |
154 | |||
155 | ///Test the replaceVectorStrInStr function | ||
156 | 1 | void testReplaceVectorStrInStr(){ | |
157 | 1 | std::vector<std::string> vecStrPattern; | |
158 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(checkReplaceVectorStrInStr("", vecStrPattern, "", "")); |
159 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(checkReplaceVectorStrInStr("something", vecStrPattern, "", "something")); |
160 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecStrPattern.push_back("key"); |
161 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(checkReplaceVectorStrInStr("", vecStrPattern, "", "")); |
162 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(checkReplaceVectorStrInStr("convert value to key", vecStrPattern, "value", "convert value to value")); |
163 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecStrPattern.push_back("value"); |
164 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(checkReplaceVectorStrInStr("convert value to key", vecStrPattern, "thing", "convert thing to thing")); |
165 | 1 | } | |
166 | |||
167 | ///Check the replaceVectorStrInStr function | ||
168 | /** @param inputStr : input string | ||
169 | * @param vecPattern : list of patterns | ||
170 | * @param replace : substitution string | ||
171 | * @param strReference : expected result | ||
172 | * @return true on success, false otherwise | ||
173 | */ | ||
174 | 5 | bool checkReplaceListStrInStr(const std::string & inputStr, const std::list<std::string> & vecPattern, const std::string & replace, | |
175 | const std::string & strReference) | ||
176 | { | ||
177 |
1/1✓ Branch 1 taken 5 times.
|
5 | std::string res(replaceListStrInStr(inputStr, vecPattern, replace)); |
178 |
2/2✓ Branch 2 taken 5 times.
✓ Branch 5 taken 5 times.
|
10 | return phoenix_check("", res, strReference); |
179 | 5 | } | |
180 | |||
181 | ///Test the replaceVectorStrInStr function | ||
182 | 1 | void testReplaceListStrInStr(){ | |
183 | 1 | std::list<std::string> vecStrPattern; | |
184 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(checkReplaceListStrInStr("", vecStrPattern, "", "")); |
185 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(checkReplaceListStrInStr("something", vecStrPattern, "", "something")); |
186 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecStrPattern.push_back("key"); |
187 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(checkReplaceListStrInStr("", vecStrPattern, "", "")); |
188 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(checkReplaceListStrInStr("convert value to key", vecStrPattern, "value", "convert value to value")); |
189 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | vecStrPattern.push_back("value"); |
190 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(checkReplaceListStrInStr("convert value to key", vecStrPattern, "thing", "convert thing to thing")); |
191 | 1 | } | |
192 | |||
193 | ///Test the phoenix_charToString function | ||
194 | 1 | void testCharToString(){ | |
195 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(phoenix_charToString("some string") == "some string"); |
196 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(phoenix_charToString(NULL) == ""); |
197 | 1 | } | |
198 | |||
199 | ///Test the phoenix_escapeStr function | ||
200 | 1 | void testEscapeString(){ | |
201 |
11/11✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 26 taken 1 times.
✓ Branch 29 taken 1 times.
✓ Branch 33 taken 1 times.
✓ Branch 36 taken 1 times.
✓ Branch 39 taken 1 times.
|
1 | phoenix_assert(phoenix_check("", phoenix_escapeStr("some string with escape's \"char\"", " '\"", "\\"), "some\\ string\\ with\\ escape\\'s\\ \\\"char\\\"")); |
202 | 1 | } | |
203 | |||
204 | ///Test the phoenix_getCommonBegining function | ||
205 | 1 | void testGetCommonBegning(){ | |
206 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
|
1 | phoenix_assert(phoenix_getCommonBegining("", "") == ""); |
207 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
|
1 | phoenix_assert(phoenix_getCommonBegining("someString", "") == ""); |
208 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
|
1 | phoenix_assert(phoenix_getCommonBegining("", "someString") == ""); |
209 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
|
1 | phoenix_assert(phoenix_getCommonBegining("someString", "someOtherString") == "some"); |
210 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 25 taken 1 times.
|
1 | phoenix_assert(phoenix_getCommonBegining("someString", "AndsomeOtherString") == ""); |
211 | 1 | } | |
212 | |||
213 | 1 | int main(int argc, char** argv){ | |
214 | 1 | testStringFunction(); | |
215 | 1 | testFindInListString(); | |
216 | 1 | testReplaceVectorStrInStr(); | |
217 | 1 | testReplaceListStrInStr(); | |
218 | 1 | testCharToString(); | |
219 | 1 | testEscapeString(); | |
220 | 1 | testGetCommonBegning(); | |
221 | 1 | return 0; | |
222 | } | ||
223 | |||
224 | |||
225 |