-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathIntegerSquareRootTest.h
More file actions
64 lines (53 loc) · 1.27 KB
/
IntegerSquareRootTest.h
File metadata and controls
64 lines (53 loc) · 1.27 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
#define BOOST_TEST_MODULE IntegerSquareRootTest
#include "../IntX.h"
#include "../Utils/Constants.h"
#include <stdexcept>
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(IntegerSquareRootTest)
BOOST_AUTO_TEST_CASE(SquareRootOfZero)
{
IntX int1 = 0;
BOOST_CHECK(IntX::IntegerSquareRoot(int1) == 0);
}
BOOST_AUTO_TEST_CASE(SquareRootOfOne)
{
IntX int1 = 1;
BOOST_CHECK(IntX::IntegerSquareRoot(int1) == 1);
}
BOOST_AUTO_TEST_CASE(SquareRootof4)
{
IntX int1 = 4;
BOOST_CHECK(IntX::IntegerSquareRoot(int1) == 2);
}
BOOST_AUTO_TEST_CASE(SquareRootof25)
{
IntX int1 = 25;
IntX res = IntX::IntegerSquareRoot(int1);
BOOST_CHECK(res == 5);
}
BOOST_AUTO_TEST_CASE(SquareRootof27)
{
IntX int1 = 27;
IntX res = IntX::IntegerSquareRoot(int1);
BOOST_CHECK(res == 5);
}
BOOST_AUTO_TEST_CASE(SquareRootofVeryBigValue)
{
IntX int1 = "783648276815623658365871365876257862874628734627835648726";
BOOST_CHECK(IntX::IntegerSquareRoot(int1).ToString() == "27993718524262253829858552106");
}
BOOST_AUTO_TEST_CASE(SquareRootofNegativeNumber)
{
try
{
IntX int1 = -25;
IntX::IntegerSquareRoot(int1);
} // end try
catch (const exception&e)
{
BOOST_CHECK(typeid(e) == typeid(ArgumentException));
return;
} // end catch
BOOST_CHECK(false);
}
BOOST_AUTO_TEST_SUITE_END()