| Directory: | ./ |
|---|---|
| File: | tmp_project/StringUtils/TESTS/TEST_ERASE_FIRST_LAST_CHARS/main.cpp |
| Date: | 2024-12-09 11:00:39 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 42 | 42 | 100.0% |
| Branches: | 129 | 129 | 100.0% |
| 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 "phoenix_assert.h" | ||
| 10 | #include "phoenix_check.h" | ||
| 11 | #include "string_function.h" | ||
| 12 | |||
| 13 | ///Check the erase first chars | ||
| 14 | /** @param testName : name of the test | ||
| 15 | * @param strExpr : string to be parsed to get a MathExpr | ||
| 16 | * @param strReference : reference string | ||
| 17 | * @return true is both strings are equal, false otherwise | ||
| 18 | */ | ||
| 19 | 4 | bool checkEraseFirstChars(const std::string & testName, const std::string & strExpr, const std::string & strReference){ | |
| 20 |
2/2✓ Branch 2 taken 4 times.
✓ Branch 5 taken 4 times.
|
8 | std::string strErase(eraseFirstCharsInStr(strExpr, " \t\n")); |
| 21 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
8 | return phoenix_check(testName + "("+strExpr+")", strErase, strReference); |
| 22 | 4 | } | |
| 23 | |||
| 24 | ///Check the erase last chars | ||
| 25 | /** @param testName : name of the test | ||
| 26 | * @param strExpr : string to be parsed to get a MathExpr | ||
| 27 | * @param strReference : reference string | ||
| 28 | * @return true is both strings are equal, false otherwise | ||
| 29 | */ | ||
| 30 | 4 | bool checkEraseLastChars(const std::string & testName, const std::string & strExpr, const std::string & strReference){ | |
| 31 |
2/2✓ Branch 2 taken 4 times.
✓ Branch 5 taken 4 times.
|
8 | std::string strErase(eraseLastCharsInStr(strExpr, " \t\n")); |
| 32 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
8 | return phoenix_check(testName + "("+strExpr+")", strErase, strReference); |
| 33 | 4 | } | |
| 34 | |||
| 35 | ///Check the erase first last chars | ||
| 36 | /** @param testName : name of the test | ||
| 37 | * @param strExpr : string to be parsed to get a MathExpr | ||
| 38 | * @param strReference : reference string | ||
| 39 | * @return true is both strings are equal, false otherwise | ||
| 40 | */ | ||
| 41 | 4 | bool checkEraseFirstLastChars(const std::string & testName, const std::string & strExpr, const std::string & strReference){ | |
| 42 |
2/2✓ Branch 2 taken 4 times.
✓ Branch 5 taken 4 times.
|
8 | std::string strErase(eraseFirstLastChars(strExpr, " \t\n")); |
| 43 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
8 | return phoenix_check(testName + "("+strExpr+")", strErase, strReference); |
| 44 | 4 | } | |
| 45 | |||
| 46 | ///Check the erase first last chars | ||
| 47 | /** @param testName : name of the test | ||
| 48 | * @param strExpr : string to be parsed to get a MathExpr | ||
| 49 | * @param strReference : reference string | ||
| 50 | * @return true is both strings are equal, false otherwise | ||
| 51 | */ | ||
| 52 | 1 | bool checkEraseFirstLastCharsVector(const std::string & testName, const std::string & strExpr, const std::string & strReference){ | |
| 53 | 1 | std::vector<std::string> vecStrExpr; | |
| 54 |
1/1✓ Branch 1 taken 1 times.
|
1 | vecStrExpr.push_back(strExpr); |
| 55 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | std::vector<std::string> strErase(eraseFirstLastChars(vecStrExpr, " \t\n")); |
| 56 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 11 taken 1 times.
|
2 | return phoenix_check(testName + "("+strExpr+")", strErase.front(), strReference); |
| 57 | 1 | } | |
| 58 | |||
| 59 | ///Test string erase first chars | ||
| 60 | 1 | void testBaseEraseFirstChars(){ | |
| 61 |
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(checkEraseFirstChars("Erase first chars 1", "one thing", "one thing")); |
| 62 |
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(checkEraseFirstChars("Erase first chars 2", " one thing", "one thing")); |
| 63 |
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(checkEraseFirstChars("Erase first chars 3", "one thing ", "one thing ")); |
| 64 |
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(checkEraseFirstChars("Erase first chars 4", " one thing ", "one thing ")); |
| 65 | 1 | } | |
| 66 | |||
| 67 | ///Test string erase last chars | ||
| 68 | 1 | void testBaseEraseLastChars(){ | |
| 69 |
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(checkEraseLastChars("Erase last chars 1", "one thing", "one thing")); |
| 70 |
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(checkEraseLastChars("Erase last chars 2", " one thing", " one thing")); |
| 71 |
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(checkEraseLastChars("Erase last chars 3", "one thing ", "one thing")); |
| 72 |
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(checkEraseLastChars("Erase last chars 4", " one thing ", " one thing")); |
| 73 | 1 | } | |
| 74 | |||
| 75 | ///Test string erase first last chars | ||
| 76 | 1 | void testBaseEraseFirstLastChars(){ | |
| 77 |
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(checkEraseFirstLastChars("Erase first last chars 1", "one thing", "one thing")); |
| 78 |
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(checkEraseFirstLastChars("Erase first last chars 2", " one thing", "one thing")); |
| 79 |
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(checkEraseFirstLastChars("Erase first last chars 3", "one thing ", "one thing")); |
| 80 |
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(checkEraseFirstLastChars("Erase first last chars 4", " one thing ", "one thing")); |
| 81 |
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(checkEraseFirstLastCharsVector("Erase first last chars 4", " one thing ", "one thing")); |
| 82 | 1 | } | |
| 83 | |||
| 84 | 1 | int main(int argc, char** argv){ | |
| 85 | 1 | testBaseEraseFirstChars(); | |
| 86 | 1 | testBaseEraseLastChars(); | |
| 87 | 1 | testBaseEraseFirstLastChars(); | |
| 88 | 1 | return 0; | |
| 89 | } | ||
| 90 | |||
| 91 | |||
| 92 |