-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
100 lines (100 loc) · 3.01 KB
/
test.cpp
File metadata and controls
100 lines (100 loc) · 3.01 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//#define CATCH_CONFIG_MAIN
//#include "matrix.h"
//#include "catch.hpp"
//#include <vector>
//#include <exception>
//
//using namespace std;
//
//TEST_CASE("Comparison") {
// SECTION("Not equal with unequal dimension") {
// vector<vector<double>> raw_matrix_A = { { 1, 3 },{ 1, 2 } };
// Matrix matrix_A(raw_matrix_A);
// vector<vector<double>> raw_matrix_B = { { 1, 3 },{ 1, 2 },{ 1, 5 } };
// Matrix matrix_B(raw_matrix_B);
// REQUIRE((matrix_A == matrix_B) == false);
// }
//
// SECTION("Not equal") {
// vector<vector<double>> raw_matrix_A = { { 1, 3 },{ 1, 2 } };
// Matrix matrix_A(raw_matrix_A);
// vector<vector<double>> raw_matrix_B = { { 1, 4},{ 1, 2} };
// Matrix matrix_B(raw_matrix_B);
// REQUIRE((matrix_A == matrix_B) == false);
// }
//}
//
//TEST_CASE("Creating") {
// SECTION("Different column size") {
// vector<vector<double>> raw_matrix = { {2, 4},{5, 6, 7} };
// REQUIRE_THROWS_AS(Matrix(raw_matrix), length_error);
// }
//
// SECTION("Empty") {
// vector<vector<double>> raw_matrix = {};
// Matrix matrix(raw_matrix);
// REQUIRE(matrix.getNumRows() == 0);
// REQUIRE(matrix.getNumColumns() == 0);
// }
//}
//
//TEST_CASE("Use constructor with default value") {
// Matrix matrix_A(10, 10, 10);
// Matrix matrix_B(10, 10, 100);
// Matrix expected_matrix(10, 10, 10000);
//
// SECTION("Without transpose") {
// Matrix result = matrix_A.multiply(matrix_B, false, 1);
// REQUIRE(result == expected_matrix);
// }
//
// SECTION("With transpose") {
// Matrix result = matrix_A.multiply(matrix_B, true, 1);
// REQUIRE(result == expected_matrix);
// }
//}
//
//TEST_CASE("Simple multiplication") {
// vector<vector<double>> raw_matrix_A = { { 1, 3 },{ 1, 2 } };
// Matrix matrix_A(raw_matrix_A);
// vector<vector<double>> raw_matrix_B = { { 1, 2, 1 },{ 3, 1, 0 } };
// Matrix matrix_B(raw_matrix_B);
//
// vector<vector<double>> raw_expected_matrx = { { 10, 5, 1 },{ 7, 4, 1 } };
// Matrix expected_matrix(raw_expected_matrx);
//
// SECTION("Without transpose") {
// Matrix result = matrix_A.multiply(matrix_B, false, 0);
// REQUIRE(result == expected_matrix);
// }
//
// SECTION("With transpose") {
// Matrix result = matrix_A.multiply(matrix_B, true, 0);
// REQUIRE(result == expected_matrix);
// }
//}
//
//TEST_CASE("Wrong multiply") {
// vector<vector<double>> raw_matrix_A = { { 1, 3, 4 },{ 1, 2, 5 }};
// Matrix matrix_A(raw_matrix_A);
// vector<vector<double>> raw_matrix_B = { { 1, 2, 1 },{ 3, 1, 0 } };
// Matrix matrix_B(raw_matrix_B);
//
// REQUIRE_THROWS_AS(matrix_A.multiply(matrix_B, false, 0), invalid_argument);
//}
//
//TEST_CASE("Two threads") {
// Matrix matrix_A(10, 10, 10);
// Matrix matrix_B(10, 10, 100);
// Matrix expected_matrix(10, 10, 10000);
//
// SECTION("Without transpose") {
// Matrix result = matrix_A.multiply(matrix_B, false, 2);
// REQUIRE(result == expected_matrix);
// }
//
// SECTION("With transpose") {
// Matrix result = matrix_A.multiply(matrix_B, true, 2);
// REQUIRE(result == expected_matrix);
// }
//}