Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 007d703

Browse filesBrowse files
committed
[utest][core] fix tream/test_parseFloat.cpp
1 parent 196558e commit 007d703
Copy full SHA for 007d703

File tree

Expand file treeCollapse file tree

2 files changed

+15
-17
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-17
lines changed

‎core/utest/Stream/test_parseFloat.cpp

Copy file name to clipboardExpand all lines: core/utest/Stream/test_parseFloat.cpp
+14-16Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* SPDX-License-Identifier: LGPL-2.1-or-later
55
*/
66

7-
#include <float.h>
8-
97
/**************************************************************************************
108
* TEST CODE
119
**************************************************************************************/
@@ -17,37 +15,37 @@ TEST_CASE ("Testing parseFloat(LookaheadMode lookahead = SKIP_ALL, char ignore =
1715
WHEN ("Only a integer (no comma) is contained in stream")
1816
{
1917
mock << "12";
20-
REQUIRE(mock.parseFloat() == 12.0f);
18+
uassert_float_equal(mock.parseFloat(), 12.0f);
2119
}
2220
WHEN ("A positive float is contained in stream")
2321
{
2422
mock << "12.34";
25-
REQUIRE(mock.parseFloat() == 12.34f);
23+
uassert_float_equal(mock.parseFloat(), 12.34f);
2624
}
2725
WHEN ("A negative float is contained in stream")
2826
{
2927
mock << "-12.34";
30-
REQUIRE(mock.parseFloat() == -12.34f);
28+
uassert_float_equal(mock.parseFloat(), -12.34f);
3129
}
3230
WHEN ("A float is prepended by digits")
3331
{
3432
mock << "abcdef12.34";
35-
REQUIRE(mock.parseFloat() == 12.34f);
33+
uassert_float_equal(mock.parseFloat(), 12.34f);
3634
}
3735
WHEN ("The integer is prepended by whitespace chars")
3836
{
3937
mock << "\r\n\t 12.34";
40-
REQUIRE(mock.parseFloat() == 12.34f);
38+
uassert_float_equal(mock.parseFloat(), 12.34f);
4139
}
4240
WHEN ("A float is provided with too many digits after the decimal point")
4341
{
4442
mock << "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870064";
45-
REQUIRE(mock.parseFloat() == Approx(3.141592654f));
43+
uassert_float_equal(mock.parseFloat(), 3.141592654f);
4644
}
4745
WHEN ("A float is larger than LONG_MAX")
4846
{
4947
mock << "602200000000000000000000.00";
50-
REQUIRE(mock.parseFloat() == Approx(6.022e23f));
48+
uassert_float_equal(mock.parseFloat(), 6.022e23f);
5149
}
5250
}
5351

@@ -58,19 +56,19 @@ TEST_CASE ("Testing parseFloat(LookaheadMode lookahead = SKIP_NONE, char ignore
5856
WHEN ("Only a integer is contained in stream")
5957
{
6058
mock << "12.34";
61-
REQUIRE(mock.parseFloat(SKIP_NONE) == 12.34f);
59+
uassert_float_equal(mock.parseFloat(SKIP_NONE), 12.34f);
6260
REQUIRE(mock.readString() == String(""));
6361
}
6462
WHEN ("The integer is prepended by digits")
6563
{
6664
mock << "abcdef12.34";
67-
REQUIRE(mock.parseFloat(SKIP_NONE) == 0);
65+
uassert_float_equal(mock.parseFloat(SKIP_NONE), 0);
6866
REQUIRE(mock.readString() == String("abcdef12.34"));
6967
}
7068
WHEN ("The integer is prepended by whitespace chars")
7169
{
7270
mock << "\r\n\t 12.34";
73-
REQUIRE(mock.parseFloat(SKIP_NONE) == 0);
71+
uassert_float_equal(mock.parseFloat(SKIP_NONE), 0);
7472
REQUIRE(mock.readString() == String("\r\n\t 12.34"));
7573
}
7674
}
@@ -82,7 +80,7 @@ TEST_CASE ("Testing parseFloat(LookaheadMode lookahead = SKIP_WHITESPACE, char i
8280
WHEN ("The integer is prepended by whitespace chars")
8381
{
8482
mock << "\r\n\t 12.34";
85-
REQUIRE(mock.parseFloat(SKIP_WHITESPACE) == 12.34f);
83+
uassert_float_equal(mock.parseFloat(SKIP_WHITESPACE), 12.34f);
8684
REQUIRE(mock.readString() == String(""));
8785
}
8886
}
@@ -95,19 +93,19 @@ TEST_CASE ("Testing parseFloat(LookaheadMode lookahead = SKIP_ALL, char ignore =
9593
WHEN ("A float is contained in stream")
9694
{
9795
mock << "12.34";
98-
REQUIRE(mock.parseFloat(SKIP_ALL, 'a') == 12.34f);
96+
uassert_float_equal(mock.parseFloat(SKIP_ALL, 'a'), 12.34f);
9997
REQUIRE(mock.readString() == String(""));
10098
}
10199
WHEN ("The float contains only ignore char values")
102100
{
103101
mock << "12a.3a4a";
104-
REQUIRE(mock.parseFloat(SKIP_ALL, 'a') == 12.34f);
102+
uassert_float_equal(mock.parseFloat(SKIP_ALL, 'a'), 12.34f);
105103
REQUIRE(mock.readString() == String(""));
106104
}
107105
WHEN ("The integer contains other than ignore chars")
108106
{
109107
mock << "1bed234";
110-
REQUIRE(mock.parseFloat(SKIP_ALL, 'a') == 1.0f);
108+
uassert_float_equal(mock.parseFloat(SKIP_ALL, 'a'), 1.0f);
111109
REQUIRE(mock.readString() == String("bed234"));
112110
}
113111
}

‎core/utest/TC_Stream.cpp

Copy file name to clipboardExpand all lines: core/utest/TC_Stream.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void TC_getTimeout(void)
3737

3838
static void TC_parseFloat(void)
3939
{
40-
//#include "Stream/test_parseFloat.cpp"
40+
#include "Stream/test_parseFloat.cpp"
4141
}
4242

4343
static void TC_parseInt(void)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.