forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomizedMatrixMultiplicationVerificationTest.java
More file actions
41 lines (33 loc) · 1.16 KB
/
RandomizedMatrixMultiplicationVerificationTest.java
File metadata and controls
41 lines (33 loc) · 1.16 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
package com.thealgorithms.randomized;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
class RandomizedMatrixMultiplicationVerificationTest {
@Test
void testCorrectMultiplication() {
int[][] a = {{1, 2}, {3, 4}};
int[][] b = {{5, 6}, {7, 8}};
int[][] c = {{19, 22}, {43, 50}};
assertTrue(RandomizedMatrixMultiplicationVerification.verify(a, b, c, 10));
}
@Test
void testIncorrectMultiplication() {
int[][] a = {{1, 2}, {3, 4}};
int[][] b = {{5, 6}, {7, 8}};
int[][] wrongC = {{20, 22}, {43, 51}};
assertFalse(RandomizedMatrixMultiplicationVerification.verify(a, b, wrongC, 10));
}
@Test
void testLargeMatrix() {
int size = 100;
int[][] a = new int[size][size];
int[][] b = new int[size][size];
int[][] c = new int[size][size];
for (int i = 0; i < size; i++) {
a[i][i] = 1;
b[i][i] = 1;
c[i][i] = 1;
}
assertTrue(RandomizedMatrixMultiplicationVerification.verify(a, b, c, 15));
}
}