-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPowTest.h
More file actions
49 lines (38 loc) · 886 Bytes
/
PowTest.h
File metadata and controls
49 lines (38 loc) · 886 Bytes
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
#define BOOST_TEST_MODULE PowTest
#include "../IntX.h"
#include <string>
#include <fstream>
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(PowTest)
BOOST_AUTO_TEST_CASE(Simple)
{
IntX intX1 = IntX(-1);
BOOST_CHECK(IntX::Pow(intX1, 17) == -1);
BOOST_CHECK(IntX::Pow(intX1, 18) == 1);
}
BOOST_AUTO_TEST_CASE(Zero)
{
IntX intX2 = IntX(0);
BOOST_CHECK(IntX::Pow(intX2, 77) == 0);
}
BOOST_AUTO_TEST_CASE(PowZero)
{
BOOST_CHECK(IntX::Pow(0, 0) == 1);
}
BOOST_AUTO_TEST_CASE(PowOne)
{
BOOST_CHECK(IntX::Pow(7, 1) == 7);
}
BOOST_AUTO_TEST_CASE(Big)
{
BOOST_CHECK(IntX::Pow(2, 65).ToString() == string("36893488147419103232"));
}
BOOST_AUTO_TEST_CASE(TwoNOut)
{
string pow2Str = IntX::Pow(2, 65536).ToString();
ofstream out_file("2n65536.txt", ios::out);
out_file << pow2Str << endl;
out_file.close();
BOOST_CHECK(true);
}
BOOST_AUTO_TEST_SUITE_END()