Skip to content

Commit 030368e

Browse files
authored
Added new tests for small values.
1 parent 8ce03d8 commit 030368e

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

tests/GMPTest.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ public function testGmpAdd()
5656
$this->assertEquals($result, $expected_result);
5757
}
5858

59+
public function testGmpAddSmall()
60+
{
61+
// Test that our GMP calls are returning the
62+
// correct result for addition of small numbers.
63+
64+
$small_a = '2';
65+
$small_b = '3';
66+
$expected_result = '5';
67+
68+
$result = $this->gmp->add($small_a, $small_b);
69+
70+
$this->assertEquals($result, $expected_result);
71+
}
72+
5973
public function testGmpSub()
6074
{
6175
// Test that our GMP calls are returning
@@ -68,6 +82,20 @@ public function testGmpSub()
6882
$this->assertEquals($result, $expected_result);
6983
}
7084

85+
public function testGmpSubSmall()
86+
{
87+
// Test that our GMP calls are returning the
88+
// correct result for subtraction of small numbers.
89+
90+
$small_a = '3';
91+
$small_b = '2';
92+
$expected_result = '1';
93+
94+
$result = $this->gmp->sub($small_a, $small_b);
95+
96+
$this->assertEquals($result, $expected_result);
97+
}
98+
7199
public function testGmpMul()
72100
{
73101
// Test that our GMP calls are returning
@@ -80,6 +108,20 @@ public function testGmpMul()
80108
$this->assertEquals($result, $expected_result);
81109
}
82110

111+
public function testGmpMulSmall()
112+
{
113+
// Test that our GMP calls are returning the
114+
// correct result for multiplication of small numbers.
115+
116+
$small_a = '3';
117+
$small_b = '2';
118+
$expected_result = '6';
119+
120+
$result = $this->gmp->mul($small_a, $small_b);
121+
122+
$this->assertEquals($result, $expected_result);
123+
}
124+
83125
public function testGmpDiv()
84126
{
85127
// Test that our GMP calls are returning
@@ -92,6 +134,20 @@ public function testGmpDiv()
92134
$this->assertEquals($result, $expected_result);
93135
}
94136

137+
public function testGmpDivSmall()
138+
{
139+
// Test that our GMP calls are returning the
140+
// correct result for division of small numbers.
141+
142+
$small_a = '6';
143+
$small_b = '2';
144+
$expected_result = '3';
145+
146+
$result = $this->gmp->div($small_a, $small_b);
147+
148+
$this->assertEquals($result, $expected_result);
149+
}
150+
95151
public function testGmpMod()
96152
{
97153
// Test that our GMP calls are returning
@@ -117,6 +173,19 @@ public function testGmpComp()
117173
$this->assertEquals($result, $expected_result);
118174
}
119175

176+
public function testGmpCompSmall()
177+
{
178+
// Test that our GMP calls are returning
179+
// the correct result for comparing two
180+
// small values.
181+
182+
$expected_result = '1';
183+
184+
$result = $this->gmp->comp('2', '3');
185+
186+
$this->assertEquals($result, $expected_result);
187+
}
188+
120189
public function testGmpInv()
121190
{
122191
// Test that our GMP calls are returning
@@ -142,6 +211,20 @@ public function testGmpPow()
142211
$this->assertEquals($result, $expected_result);
143212
}
144213

214+
public function testGmpPowSmall()
215+
{
216+
// Test that our GMP calls are returning
217+
// the correct result for raising a number
218+
// to a power.
219+
220+
$small_a = '3';
221+
$expected_result = '9';
222+
223+
$result = $this->gmp->power($small_a '2');
224+
225+
$this->assertEquals($result, $expected_result);
226+
}
227+
145228
public function testGmpNormalize()
146229
{
147230
// Test that our GMP calls are returning

0 commit comments

Comments
 (0)