1
+ /*
2
+ * Copyright (c) 2020 Arduino. All rights reserved.
3
+ */
4
+
5
+ /* *************************************************************************************
6
+ * INCLUDE
7
+ **************************************************************************************/
8
+
9
+ #undef _GNU_SOURCE
10
+
11
+ #include < catch.hpp>
12
+
13
+ #include < vector>
14
+
15
+ #include < WCharacter.h>
16
+
17
+ /* *************************************************************************************
18
+ * CONSTANTS
19
+ **************************************************************************************/
20
+
21
+ std::vector<char > const VALID_ASCII_VECT = {' ' , ' a' , ' b' , ' q' , ' \n ' , ' \r ' };
22
+
23
+ /* *************************************************************************************
24
+ * TEST CODE
25
+ **************************************************************************************/
26
+
27
+ TEST_CASE (" toAscii(...) is called with a valid ascii character" , " [toAscii-01]" )
28
+ {
29
+ std::for_each (std::begin (VALID_ASCII_VECT),
30
+ std::end (VALID_ASCII_VECT),
31
+ [](char const c)
32
+ {
33
+ REQUIRE (arduino::toAscii (c) == c);
34
+ });
35
+ }
36
+
37
+ TEST_CASE (" toAscii(...) is called with a invalid ascii character" , " [toAscii-02]" )
38
+ {
39
+ REQUIRE (arduino::toAscii (0xf7 ) == 0x77 );
40
+ }
41
+
42
+ TEST_CASE (" toAscii(...) is called with a invalid casted ascii character" , " [toAscii-03]" )
43
+ {
44
+ REQUIRE (arduino::toAscii ((unsigned char )0xf7 ) == 0x77 );
45
+ }
46
+
47
+ TEST_CASE (" toAscii(...) is called with a character larger than 1 byte" , " [toAscii-04]" )
48
+ {
49
+ REQUIRE (arduino::toAscii (0x3030 ) == 0x30 );
50
+ }
0 commit comments