File tree 2 files changed +82
-0
lines changed
src/test/java/com/thealgorithms/maths
2 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .thealgorithms .maths ;
2
+
3
+ import org .junit .jupiter .api .Assertions ;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ public class GCDTest {
7
+ @ Test
8
+ void test1 () {
9
+ Assertions .assertThrows (ArithmeticException .class , () -> GCD .gcd (-1 ,0 ));
10
+ }
11
+
12
+ @ Test
13
+ void test2 () {
14
+ Assertions .assertThrows (ArithmeticException .class , () -> GCD .gcd (10 , -2 ));
15
+ }
16
+
17
+ @ Test
18
+ void test3 () {
19
+ Assertions .assertThrows (ArithmeticException .class , () -> GCD .gcd (-5 , -3 ));
20
+ }
21
+
22
+ @ Test
23
+ void test4 () {
24
+ Assertions .assertEquals (GCD .gcd (0 , 2 ), 2 );
25
+ }
26
+
27
+ @ Test
28
+ void test5 () {
29
+ Assertions .assertEquals (GCD .gcd (10 , 0 ), 10 );
30
+ }
31
+
32
+ @ Test
33
+ void test6 () {
34
+ Assertions .assertEquals (GCD .gcd (1 , 0 ), 1 );
35
+ }
36
+
37
+ @ Test
38
+ void test7 () {
39
+ Assertions .assertEquals (GCD .gcd (9 , 6 ), 3 );
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ package com .thealgorithms .maths ;
2
+
3
+ import org .junit .jupiter .api .Assertions ;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ public class PrimeCheckTest {
7
+ @ Test
8
+ void test1 () {
9
+ Assertions .assertTrue (PrimeCheck .isPrime (2 ));
10
+ }
11
+
12
+ @ Test
13
+ void test2 () {
14
+ Assertions .assertFalse (PrimeCheck .isPrime (-1 ));
15
+ }
16
+
17
+ @ Test
18
+ void test3 () {
19
+ Assertions .assertFalse (PrimeCheck .isPrime (4 ));
20
+ }
21
+
22
+ @ Test
23
+ void test4 () {
24
+ Assertions .assertTrue (PrimeCheck .isPrime (5 ));
25
+ }
26
+
27
+ @ Test
28
+ void test5 () {
29
+ Assertions .assertFalse (PrimeCheck .isPrime (15 ));
30
+ }
31
+
32
+ @ Test
33
+ void test6 () {
34
+ Assertions .assertTrue (PrimeCheck .isPrime (11 ));
35
+ }
36
+
37
+ @ Test
38
+ void test7 () {
39
+ Assertions .assertFalse (PrimeCheck .isPrime (49 ));
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments