1
exercism fetch cpp bracket-push

bracket_push_test.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
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
#include "bracket_push.h"
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(paired_square_brackets)
{
    BOOST_REQUIRE(bracket_push::check("[]"));
}

#if defined(EXERCISM_RUN_ALL_TESTS)
BOOST_AUTO_TEST_CASE(empty_string)
{
    BOOST_REQUIRE(bracket_push::check(""));
}

BOOST_AUTO_TEST_CASE(unpaired_brackets)
{
    BOOST_REQUIRE(!bracket_push::check("[["));
}

BOOST_AUTO_TEST_CASE(wrong_ordered_brackets)
{
    BOOST_REQUIRE(!bracket_push::check("}{"));
}

BOOST_AUTO_TEST_CASE(wrong_closing_bracket)
{
    BOOST_REQUIRE(!bracket_push::check("{]"));
}

BOOST_AUTO_TEST_CASE(paired_with_whitespace)
{
    BOOST_REQUIRE(bracket_push::check("{ }"));
}

BOOST_AUTO_TEST_CASE(simple_nested_brackets)
{
    BOOST_REQUIRE(bracket_push::check("{[]}"));
}

BOOST_AUTO_TEST_CASE(several_paired_brackets)
{
    BOOST_REQUIRE(bracket_push::check("{}[]"));
}

BOOST_AUTO_TEST_CASE(paired_nested_brackets)
{
    BOOST_REQUIRE(bracket_push::check("([{}({}[])])"));
}

BOOST_AUTO_TEST_CASE(unopened_closing_brackets)
{
    BOOST_REQUIRE(!bracket_push::check("{[)][]}"));
}

BOOST_AUTO_TEST_CASE(unpaired_nested_brackets)
{
    BOOST_REQUIRE(!bracket_push::check("([{])"));
}

BOOST_AUTO_TEST_CASE(paired_wrong_nested_brackets)
{
    BOOST_REQUIRE(!bracket_push::check("[({]})"));
}

BOOST_AUTO_TEST_CASE(math_expression)
{
    BOOST_REQUIRE(bracket_push::check("(((185 + 223.85) * 15) - 543)/2"));
}

BOOST_AUTO_TEST_CASE(complex_latex_expression)
{
    BOOST_REQUIRE(bracket_push::check("\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)"));
}
#endif