-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathtest_isAscii.cpp
51 lines (39 loc) · 1.53 KB
/
test_isAscii.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
41
42
43
44
45
46
47
48
49
50
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <vector>
#include <api/WCharacter.h>
/**************************************************************************************
* CONSTANTS
**************************************************************************************/
std::vector<char> const VALID_ASCII_VECT = {' ', 'a', 'b', 'q', '\n', '\r'};
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("isAscii(...) is called with a valid ascii character", "[isAscii-01]")
{
std::for_each(std::begin(VALID_ASCII_VECT),
std::end (VALID_ASCII_VECT),
[](char const c)
{
REQUIRE(arduino::isAscii(c) == true);
});
}
TEST_CASE ("isAscii(...) is called with a invalid ascii character", "[isAscii-02]")
{
REQUIRE(arduino::isAscii(0xf7) == false);
}
TEST_CASE ("isAscii(...) is called with a invalid casted ascii character", "[isAscii-03]")
{
REQUIRE(arduino::isAscii((unsigned char)0xf7) == false);
}
TEST_CASE ("isAscii(...) is called with a character latger than 1 byte", "[isAscii-04]")
{
REQUIRE(arduino::isAscii(0x3030) == false);
}