| 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 "phoenix_assert.h" | ||
| 9 | #include "phoenix_check.h" | ||
| 10 | #include "DicoValue.h" | ||
| 11 | |||
| 12 | ///Save the given DicoValue in the given file | ||
| 13 | /** @param dv : DicoValue to be saved | ||
| 14 | * @param fileName : name of the file to be saved | ||
| 15 | * @return true on success, false otherwise | ||
| 16 | */ | ||
| 17 |
1/1✓ Branch 0 (2→3) taken 7 times.
|
7 | bool saveDico(const DicoValue & dv, const PPath & fileName){ |
| 18 |
8/8✓ Branch 0 (5→6) taken 7 times.
✓ Branch 2 (6→7) taken 7 times.
✓ Branch 4 (7→8) taken 7 times.
✓ Branch 6 (8→9) taken 7 times.
✓ Branch 8 (9→10) taken 7 times.
✓ Branch 10 (10→11) taken 7 times.
✓ Branch 12 (11→12) taken 7 times.
✓ Branch 14 (12→13) taken 7 times.
|
14 | return dv.save(fileName.replace(".txt", ".dico").replace(CMAKE_CURRENT_TEST_DIR, CMAKE_CURRENT_BUILD_DIR)); |
| 19 | } | ||
| 20 | |||
| 21 | ///Check a const DicoValue | ||
| 22 | /** @param dico : DicoValue | ||
| 23 | * @return true on success, false otherwise | ||
| 24 | */ | ||
| 25 | 1 | bool checkConstDicoValue(const DicoValue & dico){ | |
| 26 | 1 | bool b(true); | |
| 27 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
|
1 | b &= dico.getMap("NonExistingmap") == NULL; |
| 28 | 1 | return b; | |
| 29 | } | ||
| 30 | |||
| 31 | ///Test the DicoValue | ||
| 32 | /** @param fileName : name of the file to be used | ||
| 33 | * @return true on success, false otherwise | ||
| 34 | */ | ||
| 35 | 2 | bool testDicoValue(const PPath & fileName){ | |
| 36 |
1/1✓ Branch 0 (2→3) taken 2 times.
|
2 | DicoValue dv; |
| 37 |
3/3✓ Branch 0 (3→4) taken 2 times.
✓ Branch 2 (4→5) taken 1 times.
✓ Branch 3 (4→10) taken 1 times.
|
2 | if(!dv.load(fileName)){ |
| 38 |
4/4✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
✓ Branch 4 (7→8) taken 1 times.
✓ Branch 6 (8→9) taken 1 times.
|
1 | std::cerr << "testDicoValue : cannot load file '"<<fileName<<"'" << std::endl; |
| 39 | 1 | return false; | |
| 40 | } | ||
| 41 |
1/1✓ Branch 0 (10→11) taken 1 times.
|
1 | std::vector<DicoValue> & vecChild = dv.getVecChild(); |
| 42 | |||
| 43 |
3/3✓ Branch 0 (11→12) taken 1 times.
✓ Branch 2 (12→13) taken 1 times.
✓ Branch 4 (13→14) taken 1 times.
|
1 | DicoValue & value = dv.getMapChild()["key"]; |
| 44 | 1 | bool b(true); | |
| 45 |
2/2✓ Branch 0 (15→16) taken 1 times.
✓ Branch 2 (16→17) taken 1 times.
|
1 | b &= dv.getMap("NonExistingmap") == NULL; |
| 46 |
1/1✓ Branch 0 (18→19) taken 1 times.
|
1 | b &= checkConstDicoValue(dv); |
| 47 |
1/1✓ Branch 0 (19→20) taken 1 times.
|
1 | DicoValue dico; |
| 48 |
2/2✓ Branch 0 (20→21) taken 1 times.
✓ Branch 2 (21→22) taken 1 times.
|
1 | dico.setVecChild(dv.getVecChild()); |
| 49 |
2/2✓ Branch 0 (22→23) taken 1 times.
✓ Branch 2 (23→24) taken 1 times.
|
1 | dico.setMapChild(dv.getMapChild()); |
| 50 | |||
| 51 |
9/9✓ Branch 0 (24→25) taken 1 times.
✓ Branch 2 (25→26) taken 1 times.
✓ Branch 4 (26→27) taken 1 times.
✓ Branch 6 (27→28) taken 1 times.
✓ Branch 8 (28→29) taken 1 times.
✓ Branch 10 (29→30) taken 1 times.
✓ Branch 12 (30→31) taken 1 times.
✓ Branch 14 (32→33) taken 1 times.
✓ Branch 16 (33→34) taken 1 times.
|
1 | std::cout << "testDicoValue : value of key : '" << value.getValue() << "' with key '" << value.getKey() << "', vecChild.size = " << vecChild.size() << std::endl; |
| 52 |
2/2✓ Branch 0 (34→35) taken 1 times.
✓ Branch 2 (35→36) taken 1 times.
|
1 | b &= value.getValue() == "value"; |
| 53 |
1/1✓ Branch 0 (36→37) taken 1 times.
|
1 | b &= saveDico(dv, fileName); |
| 54 | 1 | return b; | |
| 55 | 2 | } | |
| 56 | |||
| 57 | ///Test the value of the given DicoValue | ||
| 58 | /** @param dv : DicoValue to be checked | ||
| 59 | * @param expectedValue : expected value | ||
| 60 | * @return true on success, false otherwise | ||
| 61 | */ | ||
| 62 | 3 | bool testDicoValueKey(const DicoValue & dv, int expectedValue){ | |
| 63 | // std::cout << "testDicoValueKey : key '" << dv.getKey() << "' with value '" << dv.getValue() << "', hasKey = " << dv.hasKey() << "', hasMap = " << dv.hasMap() << "', hasVec = " << dv.hasVec() << std::endl; | ||
| 64 |
3/3✓ Branch 0 (2→3) taken 3 times.
✓ Branch 2 (5→6) taken 3 times.
✓ Branch 4 (6→7) taken 3 times.
|
9 | return phoenix_check("testDicoValueKey", dv.getValue<int>(), expectedValue); |
| 65 | } | ||
| 66 | |||
| 67 | ///Test the DicoValue | ||
| 68 | /** @param fileName : name of the file to be used | ||
| 69 | * @return true on success, false otherwise | ||
| 70 | */ | ||
| 71 | 2 | bool testDicoValue2(const PPath & fileName){ | |
| 72 |
1/1✓ Branch 0 (2→3) taken 2 times.
|
2 | DicoValue dv; |
| 73 |
3/3✓ Branch 0 (3→4) taken 2 times.
✓ Branch 2 (4→5) taken 1 times.
✓ Branch 3 (4→10) taken 1 times.
|
2 | if(!dv.load(fileName)){ |
| 74 |
4/4✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
✓ Branch 4 (7→8) taken 1 times.
✓ Branch 6 (8→9) taken 1 times.
|
1 | std::cerr << "testDicoValue2 : cannot load file '"<<fileName<<"'" << std::endl; |
| 75 | 1 | return false; | |
| 76 | } | ||
| 77 |
4/4✓ Branch 0 (10→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 4 (12→13) taken 1 times.
✓ Branch 6 (13→14) taken 1 times.
|
1 | bool b(testDicoValueKey(dv.getMapChild()["key1"], 1)); |
| 78 |
4/4✓ Branch 0 (15→16) taken 1 times.
✓ Branch 2 (16→17) taken 1 times.
✓ Branch 4 (17→18) taken 1 times.
✓ Branch 6 (18→19) taken 1 times.
|
1 | b &= testDicoValueKey(dv.getMapChild()["key2"], 2); |
| 79 |
4/4✓ Branch 0 (20→21) taken 1 times.
✓ Branch 2 (21→22) taken 1 times.
✓ Branch 4 (22→23) taken 1 times.
✓ Branch 6 (23→24) taken 1 times.
|
1 | b &= testDicoValueKey(dv.getMapChild()["key3"], 3); |
| 80 |
2/2✓ Branch 0 (25→26) taken 1 times.
✓ Branch 2 (26→27) taken 1 times.
|
1 | b &= dv.isKeyExist("key3"); |
| 81 | |||
| 82 |
1/1✓ Branch 0 (28→29) taken 1 times.
|
1 | b &= saveDico(dv, fileName); |
| 83 | 1 | return b; | |
| 84 | 2 | } | |
| 85 | |||
| 86 | ///Test the value of the given DicoValue | ||
| 87 | /** @param dv : DicoValue to be checked | ||
| 88 | * @param expectedValue : expected value | ||
| 89 | * @return true on success, false otherwise | ||
| 90 | */ | ||
| 91 | 4 | bool testDicoValueKeyPtr(const DicoValue * dv, int expectedValue){ | |
| 92 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→8) taken 3 times.
|
4 | if(dv == NULL){ |
| 93 | 1 | std::cerr << "testDicoValueKeyPtr : DicoValue for value "<<expectedValue<<" not found!!!" << std::endl; | |
| 94 | 1 | return false; | |
| 95 | } | ||
| 96 | // std::cout << "testDicoValueKeyPtr : key '" << dv->getKey() << "' with value '" << dv->getValue() << "'" << std::endl; | ||
| 97 | 3 | return dv->getValue<int>() == expectedValue; | |
| 98 | } | ||
| 99 | |||
| 100 | ///Test the DicoValue | ||
| 101 | /** @param fileName : name of the file to be used | ||
| 102 | * @return true on success, false otherwise | ||
| 103 | */ | ||
| 104 | 2 | bool testDicoValue3(const PPath & fileName){ | |
| 105 |
1/1✓ Branch 0 (2→3) taken 2 times.
|
2 | DicoValue dv; |
| 106 |
3/3✓ Branch 0 (3→4) taken 2 times.
✓ Branch 2 (4→5) taken 1 times.
✓ Branch 3 (4→10) taken 1 times.
|
2 | if(!dv.load(fileName)){ |
| 107 |
4/4✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
✓ Branch 4 (7→8) taken 1 times.
✓ Branch 6 (8→9) taken 1 times.
|
1 | std::cerr << "testDicoValue3 : cannot load file '"<<fileName<<"'" << std::endl; |
| 108 | 1 | return false; | |
| 109 | } | ||
| 110 |
3/3✓ Branch 0 (10→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 4 (12→13) taken 1 times.
|
1 | bool b(testDicoValueKeyPtr(dv.getMap("key1"), 1)); |
| 111 |
3/3✓ Branch 0 (14→15) taken 1 times.
✓ Branch 2 (15→16) taken 1 times.
✓ Branch 4 (16→17) taken 1 times.
|
1 | b &= testDicoValueKeyPtr(dv.getMap("key2"), 2); |
| 112 |
3/3✓ Branch 0 (18→19) taken 1 times.
✓ Branch 2 (19→20) taken 1 times.
✓ Branch 4 (20→21) taken 1 times.
|
1 | b &= testDicoValueKeyPtr(dv.getMap("key3"), 3); |
| 113 |
1/1✓ Branch 0 (22→23) taken 1 times.
|
1 | b &= !testDicoValueKeyPtr(NULL, 0); |
| 114 |
1/1✓ Branch 0 (23→24) taken 1 times.
|
1 | b &= saveDico(dv, fileName); |
| 115 | 1 | return b; | |
| 116 | 2 | } | |
| 117 | |||
| 118 | ///Test the value of the given DicoValue | ||
| 119 | /** @param dv : DicoValue to be checked | ||
| 120 | * @param expectedValue : expected value | ||
| 121 | * @return true on success, false otherwise | ||
| 122 | */ | ||
| 123 | 9 | bool testDicoVecValueKeyPtr(const DicoValue * dv, int expectedValue){ | |
| 124 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→8) taken 8 times.
|
9 | if(dv == NULL){ |
| 125 | 1 | std::cerr << "testDicoVecValueKeyPtr : DicoValue for value "<<expectedValue<<" not found!!!" << std::endl; | |
| 126 | 1 | return false; | |
| 127 | } | ||
| 128 | 8 | const VecDicoValue & vecVal = dv->getVecChild(); | |
| 129 |
2/2✓ Branch 0 (10→11) taken 1 times.
✓ Branch 1 (10→15) taken 7 times.
|
8 | if(vecVal.size() != 3lu){ |
| 130 | 1 | std::cerr << "testDicoVecValueKeyPtr : expect 3 value for first value " << expectedValue << std::endl; | |
| 131 | 1 | return false; | |
| 132 | } | ||
| 133 | 7 | bool b(true); | |
| 134 |
2/2✓ Branch 0 (28→16) taken 21 times.
✓ Branch 1 (28→29) taken 7 times.
|
28 | for(int i(0); i < 3; ++i){ |
| 135 | 21 | std::cout << "testDicoVecValueKeyPtr : value["<<i<<"] = " << vecVal[i].getValue<int>() << ", expect = " << (i + expectedValue) << std::endl; | |
| 136 | 21 | b &= vecVal[i].getValue<int>() == expectedValue + i; | |
| 137 | } | ||
| 138 | 7 | return b; | |
| 139 | } | ||
| 140 | |||
| 141 | ///Test the DicoValue | ||
| 142 | /** @param fileName : name of the file to be used | ||
| 143 | * @return true on success, false otherwise | ||
| 144 | */ | ||
| 145 | 2 | bool testDicoVecValue(const PPath & fileName){ | |
| 146 |
1/1✓ Branch 0 (2→3) taken 2 times.
|
2 | DicoValue dv; |
| 147 |
3/3✓ Branch 0 (3→4) taken 2 times.
✓ Branch 2 (4→5) taken 1 times.
✓ Branch 3 (4→10) taken 1 times.
|
2 | if(!dv.load(fileName)){ |
| 148 |
4/4✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
✓ Branch 4 (7→8) taken 1 times.
✓ Branch 6 (8→9) taken 1 times.
|
1 | std::cerr << "testDicoVecValue : cannot load file '"<<fileName<<"'" << std::endl; |
| 149 | 1 | return false; | |
| 150 | } | ||
| 151 |
3/3✓ Branch 0 (10→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 4 (12→13) taken 1 times.
|
1 | bool b(testDicoVecValueKeyPtr(dv.getMap("key1"), 1)); |
| 152 |
3/3✓ Branch 0 (14→15) taken 1 times.
✓ Branch 2 (15→16) taken 1 times.
✓ Branch 4 (16→17) taken 1 times.
|
1 | b &= testDicoVecValueKeyPtr(dv.getMap("key2"), 2); |
| 153 |
3/3✓ Branch 0 (18→19) taken 1 times.
✓ Branch 2 (19→20) taken 1 times.
✓ Branch 4 (20→21) taken 1 times.
|
1 | b &= testDicoVecValueKeyPtr(dv.getMap("key3"), 3); |
| 154 |
1/1✓ Branch 0 (22→23) taken 1 times.
|
1 | b &= saveDico(dv, fileName); |
| 155 | 1 | return b; | |
| 156 | 2 | } | |
| 157 | |||
| 158 | ///Test the DicoValue | ||
| 159 | /** @param fileName : name of the file to be used | ||
| 160 | * @return true on success, false otherwise | ||
| 161 | */ | ||
| 162 | 2 | bool testDicoVecString(const PPath & fileName){ | |
| 163 |
1/1✓ Branch 0 (2→3) taken 2 times.
|
2 | DicoValue dv; |
| 164 |
3/3✓ Branch 0 (3→4) taken 2 times.
✓ Branch 2 (4→5) taken 1 times.
✓ Branch 3 (4→10) taken 1 times.
|
2 | if(!dv.load(fileName)){ |
| 165 |
4/4✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
✓ Branch 4 (7→8) taken 1 times.
✓ Branch 6 (8→9) taken 1 times.
|
1 | std::cerr << "testDicoVecString : cannot load file '"<<fileName<<"'" << std::endl; |
| 166 | 1 | return false; | |
| 167 | } | ||
| 168 |
3/3✓ Branch 0 (10→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 4 (12→13) taken 1 times.
|
1 | bool b(testDicoVecValueKeyPtr(dv.getMap("key1"), 1)); |
| 169 |
3/3✓ Branch 0 (14→15) taken 1 times.
✓ Branch 2 (15→16) taken 1 times.
✓ Branch 4 (16→17) taken 1 times.
|
1 | b &= testDicoVecValueKeyPtr(dv.getMap("key2"), 2); |
| 170 |
3/3✓ Branch 0 (18→19) taken 1 times.
✓ Branch 2 (19→20) taken 1 times.
✓ Branch 4 (20→21) taken 1 times.
|
1 | b &= testDicoVecValueKeyPtr(dv.getMap("key3"), 3); |
| 171 |
1/1✓ Branch 0 (24→25) taken 1 times.
|
2 | PVecString key3Address = {"key3"}; |
| 172 |
2/2✓ Branch 0 (26→27) taken 1 times.
✓ Branch 2 (27→28) taken 1 times.
|
1 | b &= testDicoVecValueKeyPtr(dv.getMap(key3Address), 3); |
| 173 | |||
| 174 |
1/1✓ Branch 0 (28→29) taken 1 times.
|
1 | b &= !testDicoVecValueKeyPtr(NULL, 0); |
| 175 |
1/1✓ Branch 0 (29→30) taken 1 times.
|
1 | DicoValue val; |
| 176 |
1/1✓ Branch 0 (30→31) taken 1 times.
|
1 | b &= !testDicoVecValueKeyPtr(&val, 0); |
| 177 | |||
| 178 |
1/1✓ Branch 0 (31→32) taken 1 times.
|
1 | b &= saveDico(dv, fileName); |
| 179 | 1 | return b; | |
| 180 | 2 | } | |
| 181 | |||
| 182 | ///Test the value of the given DicoValue | ||
| 183 | /** @param dv : DicoValue to be checked | ||
| 184 | * @param expectedValue : expected value | ||
| 185 | * @return true on success, false otherwise | ||
| 186 | */ | ||
| 187 | 18 | bool testDicoValueKey(const DicoValue * dv, int expectedValue){ | |
| 188 |
3/3✓ Branch 0 (2→3) taken 18 times.
✓ Branch 2 (5→6) taken 18 times.
✓ Branch 4 (6→7) taken 18 times.
|
54 | return phoenix_check("testDicoValueKey", dv->getValue<int>(), expectedValue); |
| 189 | } | ||
| 190 | |||
| 191 | ///Test the value of the given DicoValue | ||
| 192 | /** @param dv : DicoValue to be checked | ||
| 193 | * @param expectedValue : expected value | ||
| 194 | * @return true on success, false otherwise | ||
| 195 | */ | ||
| 196 | 10 | bool testDicoDicoValueKeyPtr(const DicoValue * dv, int expectedValue){ | |
| 197 |
2/2✓ Branch 0 (2→3) taken 2 times.
✓ Branch 1 (2→8) taken 8 times.
|
10 | if(dv == NULL){ |
| 198 | 2 | std::cerr << "testDicoDicoValueKeyPtr : DicoValue for value "<<expectedValue<<" not found!!!" << std::endl; | |
| 199 | 2 | return false; | |
| 200 | } | ||
| 201 | 8 | const MapDicoValue & mapVal = dv->getMapChild(); | |
| 202 |
2/2✓ Branch 0 (10→11) taken 2 times.
✓ Branch 1 (10→15) taken 6 times.
|
8 | if(mapVal.size() != 3lu){ |
| 203 | 2 | std::cerr << "testDicoDicoValueKeyPtr : expect 3 value for first value " << expectedValue << std::endl; | |
| 204 | 2 | return false; | |
| 205 | } | ||
| 206 | 6 | bool b(true); | |
| 207 |
3/3✓ Branch 0 (15→16) taken 6 times.
✓ Branch 2 (16→17) taken 6 times.
✓ Branch 4 (17→18) taken 6 times.
|
6 | b &= testDicoValueKey(dv->getMap("val1"), expectedValue); |
| 208 |
3/3✓ Branch 0 (19→20) taken 6 times.
✓ Branch 2 (20→21) taken 6 times.
✓ Branch 4 (21→22) taken 6 times.
|
6 | b &= testDicoValueKey(dv->getMap("val2"), 1 + expectedValue); |
| 209 |
3/3✓ Branch 0 (23→24) taken 6 times.
✓ Branch 2 (24→25) taken 6 times.
✓ Branch 4 (25→26) taken 6 times.
|
6 | b &= testDicoValueKey(dv->getMap("val3"), 2 + expectedValue); |
| 210 | 6 | return b; | |
| 211 | } | ||
| 212 | |||
| 213 | ///Test the DicoValue | ||
| 214 | /** @param fileName : name of the file to be used | ||
| 215 | * @return true on success, false otherwise | ||
| 216 | */ | ||
| 217 | 3 | bool testDicoDicoString(const PPath & fileName){ | |
| 218 |
1/1✓ Branch 0 (2→3) taken 3 times.
|
3 | DicoValue dv; |
| 219 |
3/3✓ Branch 0 (3→4) taken 3 times.
✓ Branch 2 (4→5) taken 1 times.
✓ Branch 3 (4→10) taken 2 times.
|
3 | if(!dv.load(fileName)){ |
| 220 |
4/4✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
✓ Branch 4 (7→8) taken 1 times.
✓ Branch 6 (8→9) taken 1 times.
|
1 | std::cerr << "testDicoDicoString : cannot load file '"<<fileName<<"'" << std::endl; |
| 221 | 1 | return false; | |
| 222 | } | ||
| 223 |
3/3✓ Branch 0 (10→11) taken 2 times.
✓ Branch 2 (11→12) taken 2 times.
✓ Branch 4 (12→13) taken 2 times.
|
2 | bool b(testDicoDicoValueKeyPtr(dv.getMap("key1"), 1)); |
| 224 |
3/3✓ Branch 0 (14→15) taken 2 times.
✓ Branch 2 (15→16) taken 2 times.
✓ Branch 4 (16→17) taken 2 times.
|
2 | b &= testDicoDicoValueKeyPtr(dv.getMap("key2"), 2); |
| 225 |
3/3✓ Branch 0 (18→19) taken 2 times.
✓ Branch 2 (19→20) taken 2 times.
✓ Branch 4 (20→21) taken 2 times.
|
2 | b &= testDicoDicoValueKeyPtr(dv.getMap("key3"), 3); |
| 226 | |||
| 227 |
1/1✓ Branch 0 (22→23) taken 2 times.
|
2 | b &= !testDicoDicoValueKeyPtr(NULL, 0); |
| 228 |
1/1✓ Branch 0 (23→24) taken 2 times.
|
2 | DicoValue val; |
| 229 |
1/1✓ Branch 0 (24→25) taken 2 times.
|
2 | b &= !testDicoDicoValueKeyPtr(&val, 0); |
| 230 | |||
| 231 |
1/1✓ Branch 0 (25→26) taken 2 times.
|
2 | b &= saveDico(dv, fileName); |
| 232 | 2 | return b; | |
| 233 | 3 | } | |
| 234 | |||
| 235 | ///Check all the good parsing | ||
| 236 | /** @param fileContent : wrong file content | ||
| 237 | * @return true on success, false otherwise | ||
| 238 | */ | ||
| 239 | 2 | bool testDicoGoodParsing(const PString & fileContent){ | |
| 240 |
2/2✓ Branch 0 (2→3) taken 2 times.
✓ Branch 2 (3→4) taken 2 times.
|
2 | PPath fileName("config.txt"); |
| 241 | 2 | bool b(true); | |
| 242 |
1/1✓ Branch 0 (5→6) taken 2 times.
|
2 | b &= fileName.saveFileContent(fileContent); |
| 243 |
1/1✓ Branch 0 (6→7) taken 2 times.
|
2 | DicoValue dico; |
| 244 |
1/1✓ Branch 0 (7→8) taken 2 times.
|
2 | b &= dico.load(fileName); |
| 245 | 2 | return b; | |
| 246 | 2 | } | |
| 247 | |||
| 248 | ///Check all the bad parsing | ||
| 249 | /** @param fileContent : wrong file content | ||
| 250 | * @return true on success, false otherwise | ||
| 251 | */ | ||
| 252 | 5 | bool testDicoBadParsing(const PString & fileContent){ | |
| 253 |
2/2✓ Branch 0 (2→3) taken 5 times.
✓ Branch 2 (3→4) taken 5 times.
|
5 | PPath fileName("config.txt"); |
| 254 | 5 | bool b(true); | |
| 255 |
1/1✓ Branch 0 (5→6) taken 5 times.
|
5 | b &= fileName.saveFileContent(fileContent); |
| 256 |
1/1✓ Branch 0 (6→7) taken 5 times.
|
5 | DicoValue dico; |
| 257 |
1/1✓ Branch 0 (7→8) taken 5 times.
|
5 | b &= !dico.load(fileName); |
| 258 | 5 | return b; | |
| 259 | 5 | } | |
| 260 | |||
| 261 | ///Check all the bad parsing | ||
| 262 | /** @param fileContent : wrong file content | ||
| 263 | * @return true on success, false otherwise | ||
| 264 | */ | ||
| 265 | 3 | bool testDicoSaveParsing(const PString & fileContent){ | |
| 266 |
2/2✓ Branch 0 (2→3) taken 3 times.
✓ Branch 2 (3→4) taken 3 times.
|
3 | PPath fileName("config_out.txt"); |
| 267 | 3 | bool b(true); | |
| 268 |
1/1✓ Branch 0 (5→6) taken 3 times.
|
3 | DicoValue dico; |
| 269 |
1/1✓ Branch 0 (6→7) taken 3 times.
|
3 | dico.setValue(fileContent); |
| 270 |
1/1✓ Branch 0 (10→11) taken 3 times.
|
3 | b &= dico.save(fileName); |
| 271 | 3 | return b; | |
| 272 | 3 | } | |
| 273 | |||
| 274 | ///Test JSON to JSON convertion | ||
| 275 | 1 | void testFromJSonToJSon(){ | |
| 276 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
|
1 | PPath fileName(CMAKE_CURRENT_TEST_DIR "/testInputDicoMapDico.json"); |
| 277 | |||
| 278 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
1 | DicoValue dv; |
| 279 |
5/5✓ Branch 0 (8→9) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 4 (14→15) taken 1 times.
✓ Branch 6 (15→16) taken 1 times.
✓ Branch 8 (16→17) taken 1 times.
|
6 | phoenix_assert(dv.load(fileName)); |
| 280 |
7/7✓ Branch 0 (25→26) taken 1 times.
✓ Branch 2 (28→29) taken 1 times.
✓ Branch 4 (31→32) taken 1 times.
✓ Branch 6 (34→35) taken 1 times.
✓ Branch 8 (35→36) taken 1 times.
✓ Branch 10 (36→37) taken 1 times.
✓ Branch 12 (37→38) taken 1 times.
|
7 | phoenix_assert(dv.save(fileName.getFileName(), "\"")); |
| 281 | |||
| 282 |
1/1✓ Branch 0 (48→49) taken 1 times.
|
1 | DicoValue compact; |
| 283 |
6/6✓ Branch 0 (51→52) taken 1 times.
✓ Branch 2 (54→55) taken 1 times.
✓ Branch 4 (57→58) taken 1 times.
✓ Branch 6 (58→59) taken 1 times.
✓ Branch 8 (59→60) taken 1 times.
✓ Branch 10 (60→61) taken 1 times.
|
6 | phoenix_assert(compact.fromString("{\"key1\": \"1\", \"key2\": \"2\", \"key3\": \"3\" }")); |
| 284 |
11/11✓ Branch 0 (70→71) taken 1 times.
✓ Branch 2 (73→74) taken 1 times.
✓ Branch 4 (76→77) taken 1 times.
✓ Branch 6 (79→80) taken 1 times.
✓ Branch 8 (80→81) taken 1 times.
✓ Branch 10 (81→82) taken 1 times.
✓ Branch 12 (82→83) taken 1 times.
✓ Branch 14 (83→84) taken 1 times.
✓ Branch 16 (86→87) taken 1 times.
✓ Branch 18 (87→88) taken 1 times.
✓ Branch 20 (88→89) taken 1 times.
|
9 | phoenix_assert(phoenix_check("Test compact JSON", compact.toString("\"", "", ""), "{\"key1\": \"1\",\"key2\": \"2\",\"key3\": \"3\"}")); |
| 285 | 1 | } | |
| 286 | |||
| 287 | 1 | int main(int argc, char** argv){ | |
| 288 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
|
1 | PPath fileName0(CMAKE_CURRENT_TEST_DIR "/testInputDico.txt"); |
| 289 | |||
| 290 |
5/5✓ Branch 0 (7→8) taken 1 times.
✓ Branch 2 (10→11) taken 1 times.
✓ Branch 4 (13→14) taken 1 times.
✓ Branch 6 (14→15) taken 1 times.
✓ Branch 8 (15→16) taken 1 times.
|
6 | phoenix_assert(testDicoValue(fileName0)); |
| 291 |
8/8✓ Branch 0 (24→25) taken 1 times.
✓ Branch 2 (27→28) taken 1 times.
✓ Branch 4 (30→31) taken 1 times.
✓ Branch 6 (31→32) taken 1 times.
✓ Branch 8 (32→33) taken 1 times.
✓ Branch 10 (33→34) taken 1 times.
✓ Branch 12 (34→35) taken 1 times.
✓ Branch 14 (35→36) taken 1 times.
|
5 | phoenix_assert(!testDicoValue(PString(fileName0 + "whichDoesnotExist"))); |
| 292 | |||
| 293 |
2/2✓ Branch 0 (45→46) taken 1 times.
✓ Branch 2 (46→47) taken 1 times.
|
1 | PPath fileName2(CMAKE_CURRENT_TEST_DIR "/testInputDicoValue.txt"); |
| 294 |
5/5✓ Branch 0 (50→51) taken 1 times.
✓ Branch 2 (53→54) taken 1 times.
✓ Branch 4 (56→57) taken 1 times.
✓ Branch 6 (57→58) taken 1 times.
✓ Branch 8 (58→59) taken 1 times.
|
6 | phoenix_assert(testDicoValue2(fileName2)); |
| 295 |
8/8✓ Branch 0 (67→68) taken 1 times.
✓ Branch 2 (70→71) taken 1 times.
✓ Branch 4 (73→74) taken 1 times.
✓ Branch 6 (74→75) taken 1 times.
✓ Branch 8 (75→76) taken 1 times.
✓ Branch 10 (76→77) taken 1 times.
✓ Branch 12 (77→78) taken 1 times.
✓ Branch 14 (78→79) taken 1 times.
|
5 | phoenix_assert(!testDicoValue2(PString(fileName2 + "whichDoesnotExist"))); |
| 296 | |||
| 297 |
2/2✓ Branch 0 (88→89) taken 1 times.
✓ Branch 2 (89→90) taken 1 times.
|
1 | PPath fileName3(CMAKE_CURRENT_TEST_DIR "/testInputDicoValue.txt"); |
| 298 |
5/5✓ Branch 0 (93→94) taken 1 times.
✓ Branch 2 (96→97) taken 1 times.
✓ Branch 4 (99→100) taken 1 times.
✓ Branch 6 (100→101) taken 1 times.
✓ Branch 8 (101→102) taken 1 times.
|
6 | phoenix_assert(testDicoValue3(fileName3)); |
| 299 |
8/8✓ Branch 0 (110→111) taken 1 times.
✓ Branch 2 (113→114) taken 1 times.
✓ Branch 4 (116→117) taken 1 times.
✓ Branch 6 (117→118) taken 1 times.
✓ Branch 8 (118→119) taken 1 times.
✓ Branch 10 (119→120) taken 1 times.
✓ Branch 12 (120→121) taken 1 times.
✓ Branch 14 (121→122) taken 1 times.
|
5 | phoenix_assert(!testDicoValue3(PString(fileName3 + "whichDoesnotExist"))); |
| 300 | |||
| 301 |
2/2✓ Branch 0 (131→132) taken 1 times.
✓ Branch 2 (132→133) taken 1 times.
|
1 | PPath fileNameVec(CMAKE_CURRENT_TEST_DIR "/testInputDicoVecValue.txt"); |
| 302 |
5/5✓ Branch 0 (136→137) taken 1 times.
✓ Branch 2 (139→140) taken 1 times.
✓ Branch 4 (142→143) taken 1 times.
✓ Branch 6 (143→144) taken 1 times.
✓ Branch 8 (144→145) taken 1 times.
|
6 | phoenix_assert(testDicoVecValue(fileNameVec)); |
| 303 |
8/8✓ Branch 0 (153→154) taken 1 times.
✓ Branch 2 (156→157) taken 1 times.
✓ Branch 4 (159→160) taken 1 times.
✓ Branch 6 (160→161) taken 1 times.
✓ Branch 8 (161→162) taken 1 times.
✓ Branch 10 (162→163) taken 1 times.
✓ Branch 12 (163→164) taken 1 times.
✓ Branch 14 (164→165) taken 1 times.
|
5 | phoenix_assert(!testDicoVecValue(PString(fileNameVec + "whichDoesnotExist"))); |
| 304 | |||
| 305 |
2/2✓ Branch 0 (174→175) taken 1 times.
✓ Branch 2 (175→176) taken 1 times.
|
1 | PPath fileNameVecString(CMAKE_CURRENT_TEST_DIR "/testInputDicoVecString.txt"); |
| 306 |
5/5✓ Branch 0 (179→180) taken 1 times.
✓ Branch 2 (182→183) taken 1 times.
✓ Branch 4 (185→186) taken 1 times.
✓ Branch 6 (186→187) taken 1 times.
✓ Branch 8 (187→188) taken 1 times.
|
6 | phoenix_assert(testDicoVecString(fileNameVecString)); |
| 307 |
8/8✓ Branch 0 (196→197) taken 1 times.
✓ Branch 2 (199→200) taken 1 times.
✓ Branch 4 (202→203) taken 1 times.
✓ Branch 6 (203→204) taken 1 times.
✓ Branch 8 (204→205) taken 1 times.
✓ Branch 10 (205→206) taken 1 times.
✓ Branch 12 (206→207) taken 1 times.
✓ Branch 14 (207→208) taken 1 times.
|
5 | phoenix_assert(!testDicoVecString(PString(fileNameVecString + "whichDoesnotExist"))); |
| 308 | |||
| 309 |
2/2✓ Branch 0 (217→218) taken 1 times.
✓ Branch 2 (218→219) taken 1 times.
|
1 | PPath fileNameDicoString(CMAKE_CURRENT_TEST_DIR "/testInputDicoMapDico.txt"); |
| 310 |
5/5✓ Branch 0 (222→223) taken 1 times.
✓ Branch 2 (225→226) taken 1 times.
✓ Branch 4 (228→229) taken 1 times.
✓ Branch 6 (229→230) taken 1 times.
✓ Branch 8 (230→231) taken 1 times.
|
6 | phoenix_assert(testDicoDicoString(fileNameDicoString)); |
| 311 |
8/8✓ Branch 0 (239→240) taken 1 times.
✓ Branch 2 (242→243) taken 1 times.
✓ Branch 4 (245→246) taken 1 times.
✓ Branch 6 (246→247) taken 1 times.
✓ Branch 8 (247→248) taken 1 times.
✓ Branch 10 (248→249) taken 1 times.
✓ Branch 12 (249→250) taken 1 times.
✓ Branch 14 (250→251) taken 1 times.
|
6 | phoenix_assert(!testDicoDicoString(PString(fileNameDicoString + "whichDoesnotExist"))); |
| 312 | |||
| 313 | //Test with a JSON | ||
| 314 |
7/7✓ Branch 0 (262→263) taken 1 times.
✓ Branch 2 (265→266) taken 1 times.
✓ Branch 4 (268→269) taken 1 times.
✓ Branch 6 (269→270) taken 1 times.
✓ Branch 8 (270→271) taken 1 times.
✓ Branch 10 (271→272) taken 1 times.
✓ Branch 12 (272→273) taken 1 times.
|
6 | phoenix_assert(testDicoDicoString(PPath(CMAKE_CURRENT_TEST_DIR "/testInputDicoMapDico.json"))); |
| 315 | |||
| 316 |
6/6✓ Branch 0 (283→284) taken 1 times.
✓ Branch 2 (286→287) taken 1 times.
✓ Branch 4 (289→290) taken 1 times.
✓ Branch 6 (290→291) taken 1 times.
✓ Branch 8 (291→292) taken 1 times.
✓ Branch 10 (292→293) taken 1 times.
|
6 | phoenix_assert(testDicoBadParsing("")); |
| 317 |
6/6✓ Branch 0 (302→303) taken 1 times.
✓ Branch 2 (305→306) taken 1 times.
✓ Branch 4 (308→309) taken 1 times.
✓ Branch 6 (309→310) taken 1 times.
✓ Branch 8 (310→311) taken 1 times.
✓ Branch 10 (311→312) taken 1 times.
|
6 | phoenix_assert(testDicoGoodParsing("42")); |
| 318 |
6/6✓ Branch 0 (321→322) taken 1 times.
✓ Branch 2 (324→325) taken 1 times.
✓ Branch 4 (327→328) taken 1 times.
✓ Branch 6 (328→329) taken 1 times.
✓ Branch 8 (329→330) taken 1 times.
✓ Branch 10 (330→331) taken 1 times.
|
6 | phoenix_assert(testDicoGoodParsing("key other")); |
| 319 |
6/6✓ Branch 0 (340→341) taken 1 times.
✓ Branch 2 (343→344) taken 1 times.
✓ Branch 4 (346→347) taken 1 times.
✓ Branch 6 (347→348) taken 1 times.
✓ Branch 8 (348→349) taken 1 times.
✓ Branch 10 (349→350) taken 1 times.
|
6 | phoenix_assert(testDicoBadParsing("{ key1 {")); |
| 320 |
6/6✓ Branch 0 (359→360) taken 1 times.
✓ Branch 2 (362→363) taken 1 times.
✓ Branch 4 (365→366) taken 1 times.
✓ Branch 6 (366→367) taken 1 times.
✓ Branch 8 (367→368) taken 1 times.
✓ Branch 10 (368→369) taken 1 times.
|
6 | phoenix_assert(testDicoBadParsing("{ {")); |
| 321 |
6/6✓ Branch 0 (378→379) taken 1 times.
✓ Branch 2 (381→382) taken 1 times.
✓ Branch 4 (384→385) taken 1 times.
✓ Branch 6 (385→386) taken 1 times.
✓ Branch 8 (386→387) taken 1 times.
✓ Branch 10 (387→388) taken 1 times.
|
6 | phoenix_assert(testDicoBadParsing("{ °")); |
| 322 |
6/6✓ Branch 0 (397→398) taken 1 times.
✓ Branch 2 (400→401) taken 1 times.
✓ Branch 4 (403→404) taken 1 times.
✓ Branch 6 (404→405) taken 1 times.
✓ Branch 8 (405→406) taken 1 times.
✓ Branch 10 (406→407) taken 1 times.
|
6 | phoenix_assert(testDicoBadParsing("{ key1: °")); |
| 323 |
6/6✓ Branch 0 (416→417) taken 1 times.
✓ Branch 2 (419→420) taken 1 times.
✓ Branch 4 (422→423) taken 1 times.
✓ Branch 6 (423→424) taken 1 times.
✓ Branch 8 (424→425) taken 1 times.
✓ Branch 10 (425→426) taken 1 times.
|
6 | phoenix_assert(testDicoSaveParsing("Just some text")); |
| 324 |
6/6✓ Branch 0 (435→436) taken 1 times.
✓ Branch 2 (438→439) taken 1 times.
✓ Branch 4 (441→442) taken 1 times.
✓ Branch 6 (442→443) taken 1 times.
✓ Branch 8 (443→444) taken 1 times.
✓ Branch 10 (444→445) taken 1 times.
|
6 | phoenix_assert(testDicoSaveParsing("Just some text\nwith new line")); |
| 325 |
6/6✓ Branch 0 (454→455) taken 1 times.
✓ Branch 2 (457→458) taken 1 times.
✓ Branch 4 (460→461) taken 1 times.
✓ Branch 6 (461→462) taken 1 times.
✓ Branch 8 (462→463) taken 1 times.
✓ Branch 10 (463→464) taken 1 times.
|
5 | phoenix_assert(testDicoSaveParsing("Just some text with spécial char/")); |
| 326 |
1/1✓ Branch 0 (471→472) taken 1 times.
|
1 | testFromJSonToJSon(); |
| 327 | 1 | return 0; | |
| 328 | 1 | } | |
| 329 | |||
| 330 | |||
| 331 |