-
Notifications
You must be signed in to change notification settings - Fork 1
/
Test.cpp
67 lines (61 loc) · 1.66 KB
/
Test.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* @file Test.cpp
* @author Shmuel.Lavian
* @brief
* @version 0.1
* @date 2021-04-20
*
* @copyright Copyright (c) 2021
*
*/
#include "doctest.h"
#include "NumberWithUnits.hpp"
using namespace ariel;
using namespace std;
TEST_CASE("Input") {
ifstream units_file{"units.txt"};
}
TEST_CASE("Wrong Input") {
ifstream units_file{"units.txt"};
NumberWithUnits::read_units(units_file);
NumberWithUnits distance(5,"km");
NumberWithUnits weight(5,"kg");
CHECK_THROWS(distance+weight);
CHECK_THROWS(distance-weight);
CHECK_THROWS(weight+distance);
CHECK_THROWS(weight-distance);
}
TEST_CASE("Calculation") {
ifstream units_file{"units.txt"};
NumberWithUnits::read_units(units_file);
NumberWithUnits distance(5,"km");
NumberWithUnits distance2(6,"km");
NumberWithUnits distance3(4,"km");
NumberWithUnits negative_distance(-5,"km");
NumberWithUnits weight(5,"kg");
NumberWithUnits weight2(5,"kg");
NumberWithUnits weight3(10,"kg");
CHECK(distance < distance2);
CHECK(distance <= distance2);
CHECK(distance2 > distance);
CHECK(distance2 >= distance);
CHECK(distance2 != distance);
CHECK(distance == distance);
CHECK(+distance == distance);
CHECK(-distance == negative_distance);
CHECK(-distance != distance);
distance++;
CHECK(distance != distance);
CHECK(distance != weight);
CHECK(distance == distance2);
distance--;
distance--;
CHECK(distance == distance3);
CHECK(distance != distance2);
CHECK((weight+weight2) == weight3);
weight++;
weight3++;
CHECK((weight+weight2) == weight3);
weight2+=weight;
CHECK(weight2 == weight3);
}