-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathtest_toFloat.cpp
36 lines (29 loc) · 1.01 KB
/
test_toFloat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <String.h>
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Testing String::toFloat when string is empty", "[String-toFloat-01]")
{
arduino::String str;
float const val = str.toFloat();
REQUIRE(val == 0.0f);
}
TEST_CASE ("Testing String::toFloat when string contains no number", "[String-toFloat-02]")
{
arduino::String str("abc");
float const val = str.toFloat();
REQUIRE(val == 0.0f);
}
TEST_CASE ("Testing String::toFloat when string contains a number", "[String-toFloat-03]")
{
arduino::String str("-1.2345");
float const val = str.toFloat();
REQUIRE(val == -1.2345f);
}