MCPcopy Create free account
hub / github.com/davisking/dlib / bigint_kernel_test

Function bigint_kernel_test

dlib/test/bigint.cpp:90–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 typename bint
89 >
90 void bigint_kernel_test (
91 )
92 /*!
93 requires
94 - bint is an implementation of bigint/bigint_kernel_abstract.h
95 ensures
96 - runs tests on bint for compliance with the specs
97 !*/
98 {
99 using namespace bigint_kernel_test_helpers;
100 using namespace relational_operators;
101 istringstream sin;
102 ostringstream sout;
103
104 bint i = 0;
105 bint a(5), b, c(0);
106
107 DLIB_TEST(5 - a == 0);
108 DLIB_TEST(a - 5 == 0);
109
110 DLIB_TEST(0 - c == 0);
111 DLIB_TEST(c - 0 == 0);
112
113 DLIB_TEST(0 + c == 0);
114 DLIB_TEST(c + 0 == 0);
115
116 DLIB_TEST(0 + a == 5);
117 DLIB_TEST(a + 0 == 5);
118
119 DLIB_TEST(0 - b == 0);
120 DLIB_TEST(b - 0 == 0);
121
122 DLIB_TEST(0 + b == 0);
123 DLIB_TEST(b + 0 == 0);
124
125 DLIB_TEST(i == 0);
126 DLIB_TEST(a == 5);
127 DLIB_TEST(b == 0);
128 DLIB_TEST(c == 0);
129
130
131
132 a -= 5;
133 DLIB_TEST(a == 0);
134
135
136
137 for (int k = 0; k < 100; ++k)
138 {
139 // compute the factorial of k using the O(n) multiplication algorithm
140 a = short_fact<bint>(k);
141 // compute the factorial of k using the full blown big int
142 // multiplication algorithm.
143 b = big_fact<bint>(k);
144 // compute the square of the factorial of k using the full blown
145 // big int multiplication algorithm.
146 c = a*b;
147 // make sure a and b ended up being the same number

Callers

nothing calls this directly

Calls 5

print_spinnerFunction · 0.85
serializeFunction · 0.70
deserializeFunction · 0.70
strMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected