Directory: | ./ |
---|---|
File: | tmp_project/PhoenixString/TESTS/TEST_PSTRING/main.cpp |
Date: | 2024-07-27 10:53:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 65 | 65 | 100.0% |
Branches: | 209 | 209 | 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 | |||
12 | #include "PString.h" | ||
13 | |||
14 | ///Check string lower expression | ||
15 | /** @param testName : name of the test | ||
16 | * @param strValue : string to be tested | ||
17 | * @param strReference : reference string | ||
18 | * @return true is both strings are equal, false otherwise | ||
19 | */ | ||
20 | 22 | bool checkString(const std::string & testName, const std::string & strValue, const std::string & strReference){ | |
21 | 22 | return phoenix_check(testName, strValue, strReference); | |
22 | } | ||
23 | |||
24 | ///Test the is lower/upper case | ||
25 | 1 | void testPString(){ | |
26 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | PString baseStr("baseString"); |
27 |
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(checkString("Test constructor", baseStr, "baseString")); |
28 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString checkEqual; |
29 |
1/1✓ Branch 1 taken 1 times.
|
1 | checkEqual = baseStr; |
30 |
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(checkString("Test equal", checkEqual, "baseString")); |
31 | |||
32 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString copyString(baseStr); |
33 |
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(checkString("Test copy constructor", copyString, "baseString")); |
34 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString equalOperatorStr; |
35 |
1/1✓ Branch 1 taken 1 times.
|
1 | equalOperatorStr = baseStr; |
36 |
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(checkString("Test equal operator str", equalOperatorStr, "baseString")); |
37 | |||
38 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString equalOperatorFluxStr; |
39 |
1/1✓ Branch 1 taken 1 times.
|
1 | equalOperatorFluxStr = baseStr; |
40 |
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(checkString("Test << operator str", equalOperatorFluxStr, "baseString")); |
41 | |||
42 |
1/1✓ Branch 1 taken 1 times.
|
1 | baseStr += " end"; |
43 |
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(checkString("Test += string", baseStr, "baseString end")); |
44 | |||
45 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString valDouble; |
46 |
1/1✓ Branch 1 taken 1 times.
|
1 | valDouble = 42.0; |
47 |
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(checkString("Test equal operator double", valDouble, "42")); |
48 | |||
49 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString valFloat; |
50 |
1/1✓ Branch 1 taken 1 times.
|
1 | valFloat = 42.0f; |
51 |
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(checkString("Test equal operator float", valFloat, "42")); |
52 | |||
53 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString valDoubleFlux; |
54 |
1/1✓ Branch 1 taken 1 times.
|
1 | valDoubleFlux << 42.0; |
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 24 taken 1 times.
|
1 | phoenix_assert(checkString("Test << operator double", valDoubleFlux, "42")); |
56 | |||
57 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString valFloatFlux; |
58 |
1/1✓ Branch 1 taken 1 times.
|
1 | valFloatFlux << 42.0f; |
59 |
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(checkString("Test << operator float", valFloatFlux, "42")); |
60 | |||
61 |
1/1✓ Branch 1 taken 1 times.
|
1 | valDouble += 3.14; |
62 |
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(checkString("Test += operator double", valDouble, "423.14")); |
63 | |||
64 |
1/1✓ Branch 1 taken 1 times.
|
1 | valFloat += 3.14f; |
65 |
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(checkString("Test += operator float", valFloat, "423.14")); |
66 | |||
67 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString resAdd = valDouble + valFloat; |
68 |
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(checkString("Test + operator PString", resAdd, "423.14423.14")); |
69 | |||
70 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString resAddDouble; |
71 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 11 taken 1 times.
|
1 | resAddDouble = PString("double ") + 3.14; |
72 |
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(checkString("Test + operator double", resAddDouble, "double 3.14")); |
73 | |||
74 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString resAddFloat; |
75 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 11 taken 1 times.
|
1 | resAddFloat = PString("float ") + 3.14; |
76 |
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(checkString("Test + operator float", resAddFloat, "float 3.14")); |
77 | |||
78 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
|
3 | PString strA("str1"), strB("str2"), resResAB, resFluxAB; |
79 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | resResAB = strA + strB; |
80 |
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(checkString("Test + operator PString", resResAB, "str1str2")); |
81 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | resFluxAB << strA << strB; |
82 |
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(checkString("Test << operator PString", resFluxAB, "str1str2")); |
83 | |||
84 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | PString strAddStr("Some string"); |
85 |
1/1✓ Branch 1 taken 1 times.
|
1 | strAddStr += " other string"; |
86 |
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(checkString("Test += operator std::string", strAddStr, "Some string other string")); |
87 | |||
88 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
2 | PString strAddFluxStr("Some string"); |
89 |
1/1✓ Branch 1 taken 1 times.
|
1 | strAddFluxStr << " other string"; |
90 |
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(checkString("Test << operator std::string", strAddFluxStr, "Some string other string")); |
91 | |||
92 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString strFlux; |
93 |
1/1✓ Branch 1 taken 1 times.
|
1 | strFlux << strAddFluxStr; |
94 |
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(checkString("Test << operator PString", strFlux, "Some string other string")); |
95 | |||
96 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | strFlux += std::string(" and the end"); |
97 |
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(checkString("Test += operator std::string", strFlux, "Some string other string and the end")); |
98 | |||
99 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | strFlux << std::string("."); |
100 |
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(checkString("Test += operator std::string", strFlux, "Some string other string and the end.")); |
101 | |||
102 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | strA << (strFlux << strAddFluxStr); |
103 | 1 | } | |
104 | |||
105 | 1 | int main(int argc, char** argv){ | |
106 | 1 | testPString(); | |
107 | 1 | return 0; | |
108 | } | ||
109 | |||
110 | |||
111 |