Skip to content

Commit da696a0

Browse files
committed
Testing arduino string
1 parent 9fa0de9 commit da696a0

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

src/arduino/noniso.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ extern char* ultoa( unsigned long value, char *string, int radix )
166166
}
167167

168168
char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
169-
asm(".global _printf_float");
169+
//asm(".global _printf_float");
170170

171171
char fmt[20];
172172
sprintf(fmt, "%%%d.%df", width, prec);

test/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ using namespace fakeit;
1010
#include "test_stream.h"
1111
#include "test_serial.h"
1212
#include "test_client.h"
13+
#include "test_arduino_string.h"
1314

1415
#ifdef UNIT_TEST
1516

@@ -27,6 +28,8 @@ int main(int argc, char **argv)
2728
{
2829
UNITY_BEGIN();
2930

31+
RUN_TEST_GROUP(ArduinoStringTest);
32+
3033
RUN_TEST_GROUP(ArduinoContextTest);
3134
RUN_TEST_GROUP(FunctionTest);
3235
RUN_TEST_GROUP(PrintTest);

test/test_arduino_string.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifdef UNIT_TEST
2+
3+
namespace ArduinoStringTest
4+
{
5+
void test_constructors(void)
6+
{
7+
String string01 = "Hello String";
8+
String string02 = String('a');
9+
String string03 = String("This is a string");
10+
String string04 = String(string03 + " with more");
11+
String string05 = String(13);
12+
String string06 = String(1000, DEC);
13+
String string07 = String(45, HEX);
14+
String string08 = String(255, BIN);
15+
String string09 = String(20000L, DEC);
16+
String string10 = String(5.698, 3);
17+
18+
TEST_ASSERT_EQUAL_STRING("Hello String", string01.c_str());
19+
TEST_ASSERT_EQUAL_STRING("a", string02.c_str());
20+
TEST_ASSERT_EQUAL_STRING("This is a string", string03.c_str());
21+
TEST_ASSERT_EQUAL_STRING("This is a string with more", string04.c_str());
22+
23+
TEST_ASSERT_EQUAL_STRING("13", string05.c_str());
24+
TEST_ASSERT_EQUAL_STRING("1000", string06.c_str());
25+
TEST_ASSERT_EQUAL_STRING("2d", string07.c_str());
26+
TEST_ASSERT_EQUAL_STRING("11111111", string08.c_str());
27+
TEST_ASSERT_EQUAL_STRING("20000", string09.c_str());
28+
TEST_ASSERT_EQUAL_STRING("5.698", string10.c_str());
29+
}
30+
31+
void run_tests()
32+
{
33+
RUN_TEST(ArduinoStringTest::test_constructors);
34+
}
35+
}
36+
37+
#endif

0 commit comments

Comments
 (0)