-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_connectivity_matrix.cpp
50 lines (44 loc) · 1.33 KB
/
test_connectivity_matrix.cpp
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
/**
* 9/25/2020
* Created by Karel Chanivecky Garcia.
* A01052674
*
* Clinton Fernandes
* A01 182 058
*
* BCIT CST
* Set O Datacomm
* COMP - 3522
*
* Assignment 1
*/
#define CATCH_CONFIG_MAIN
#include "Connectivity_Matrix.hpp"
#include "catch.hpp"
TEST_CASE( "CONNECTIVITY all values are correct" ) {
vector<double> values{ 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 };
vector<string> pageNames{ "A", "B", "C" };
vector<vector<double>> expected{{ 0.0, 1.0, 0.0 },
{ 1.0, 0.0, 1.0 },
{ 1.0, 1.0, 0.0 }};
Connectivity_Matrix result{ values, pageNames };
REQUIRE( expected == result.get_matrix());
}
TEST_CASE( "CONNECTIVITY incorrect size throws exception" ) {
vector<double> values{ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 };
vector<string> pageNames{ "A", "B", "C" };
bool exception_thrown = false;
try {
Connectivity_Matrix result{ values, pageNames };
} catch ( invalid_argument &e ) {
exception_thrown = true;
}
REQUIRE( exception_thrown );
}
TEST_CASE( "CONNECTIVITY matrix size 1" ) {
vector<double> values{ 0.0 };
vector<string> pageNames{ "A" };
vector<vector<double>> expected{{ 0.0 }};
Connectivity_Matrix result{ values, pageNames };
REQUIRE( expected == result.get_matrix());
}