-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCustomAlphabetTest.h
More file actions
66 lines (55 loc) · 1.17 KB
/
CustomAlphabetTest.h
File metadata and controls
66 lines (55 loc) · 1.17 KB
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
#define BOOST_TEST_MODULE ConstructorTest
#include "../IntX.h"
#include "../Utils/Constants.h"
#include <vector>
#include <stdexcept>
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(CustomAlphabetTest)
BOOST_AUTO_TEST_CASE(AlphabetNull)
{
try
{
IntX::Parse("", 20, "");
} // end try
catch (const exception&e)
{
BOOST_CHECK(typeid(e) == typeid(ArgumentNullException));
return;
} // end catch
BOOST_CHECK(false);
}
BOOST_AUTO_TEST_CASE(AlphabetShort)
{
try
{
IntX::Parse("", 20, "1234");
} // end try
catch (const exception&e)
{
BOOST_CHECK(typeid(e) == typeid(ArgumentException));
return;
} // end catch
BOOST_CHECK(false);
}
BOOST_AUTO_TEST_CASE(AlphabetRepeatingChars)
{
try
{
IntX::Parse("", 20, "0123456789ABCDEFGHIJ0");
} // end try
catch (const exception&e)
{
BOOST_CHECK(typeid(e) == typeid(ArgumentException));
return;
} // end catch
BOOST_CHECK(false);
}
BOOST_AUTO_TEST_CASE(Parse)
{
BOOST_CHECK(19 * 20 + 18 == (int)IntX::Parse("JI", 20, "0123456789ABCDEFGHIJ"));
}
BOOST_AUTO_TEST_CASE(ToStringTest)
{
BOOST_CHECK("JI" == IntX(19 * 20 + 18).ToString(20, string("0123456789ABCDEFGHIJ")));
}
BOOST_AUTO_TEST_SUITE_END()