~aleteoryx/muditaos

ref: df6d7848f55a94cfeb999363169a6ccf297ce3e4 muditaos/module-services/service-cellular/tests/unittest_DTMFCode.cpp -rw-r--r-- 2.2 KiB
df6d7848 — Lefucjusz [BH-2056] Add bedside lamp settings 1 year, 4 months ago
                                                                                
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <catch2/catch.hpp>
#include "DTMFCode.hpp"

TEST_CASE("DTMFCode")
{
    SECTION("Parse from char")
    {
        auto code = DTMFCode('0');
        REQUIRE(code.getDigitASCIICode() == '0');
        REQUIRE(std::string(code) == "\"0\"");
    }
    SECTION("Parse from char 2")
    {
        auto code = DTMFCode('9');
        REQUIRE(code.getDigitASCIICode() == '9');
        REQUIRE(std::string(code) == "\"9\"");
    }
    SECTION("Parse from char 3")
    {
        auto code = DTMFCode('*');
        REQUIRE(code.getDigitASCIICode() == '*');
        REQUIRE(std::string(code) == "\"*\"");
    }
    SECTION("Parse from char 4")
    {
        auto code = DTMFCode('#');
        REQUIRE(code.getDigitASCIICode() == '#');
        REQUIRE(std::string(code) == "\"#\"");
    }

    SECTION("Parse from string")
    {
        auto code = DTMFCode("0");
        REQUIRE(code.getDigitASCIICode() == '0');
        REQUIRE(std::string(code) == "\"0\"");
    }
    SECTION("Parse from string 2")
    {
        auto code = DTMFCode("9");
        REQUIRE(code.getDigitASCIICode() == '9');
        REQUIRE(std::string(code) == "\"9\"");
    }
    SECTION("Parse from string 3")
    {
        auto code = DTMFCode("*");
        REQUIRE(code.getDigitASCIICode() == '*');
        REQUIRE(std::string(code) == "\"*\"");
    }
    SECTION("Parse from string 4")
    {
        auto code = DTMFCode("#");
        REQUIRE(code.getDigitASCIICode() == '#');
        REQUIRE(std::string(code) == "\"#\"");
    }

    SECTION("Parse from char - incorrect input")
    {
        REQUIRE_THROWS_AS(DTMFCode('a'), std::out_of_range);
    }
    SECTION("Parse from char - incorrect input 2")
    {
        REQUIRE_THROWS_AS(DTMFCode('!'), std::out_of_range);
    }
    SECTION("Parse from string - incorrect input 1")
    {
        REQUIRE_THROWS_AS(DTMFCode("a"), std::out_of_range);
    }
    SECTION("Parse from string - incorrect input 2")
    {
        REQUIRE_THROWS_AS(DTMFCode("!"), std::out_of_range);
    }
    SECTION("Parse from string - incorrect input 3")
    {
        REQUIRE_THROWS_AS(DTMFCode("12"), std::out_of_range);
    }
}