-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathtest_toFloat.cpp
40 lines (32 loc) · 1.09 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
37
38
39
40
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <api/String.h>
#include "StringPrinter.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);
}