-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_1.cpp
98 lines (93 loc) · 2.58 KB
/
test_1.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
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
//
// Created by krave on 09/12/2020.
//
#include <iostream>
#include "gtest/gtest.h"
using namespace std;
#include "Bankomat_1.h"
using namespace ::testing;
TEST(test1, init){
Bankomat b;
ASSERT_EQ("KravetsBank", b.NameBank());
ASSERT_TRUE(b.open_bankomat("2312"));
}
TEST(test1, copy){
Bankomat b1("NewBank", "12344321");
Bankomat b2(b1);
ASSERT_EQ("NewBank", b2.NameBank());
ASSERT_TRUE(b2.open_bankomat("12344321"));
ASSERT_EQ("NewBank", b1.NameBank());
ASSERT_TRUE(b1.open_bankomat("12344321"));
}
TEST(test1, presuv){
Bankomat b1("OldBank", "0000");
Bankomat b2(move(b1));
ASSERT_EQ("OldBank", b2.NameBank());
ASSERT_EQ("", b1.NameBank());
}
TEST(test1, card_not_exist){
string exc;
Bankomat b("KravetsBank");
try{
b.insert_card("0000000000000000", 0000);
ASSERT_TRUE(false);
}
catch (WrongOperation &e){
exc = e.message();
}
ASSERT_EQ("this account does not exist", exc);
}
TEST(test1, card_is_inside){
Bankomat b("KravetsBank");
try{
b.add_account("1234567812345678", 1111, "SomeBank");
b.add_account("1111222233334444", 1111, "AnyBank");
ASSERT_TRUE(b.insert_card("1234567812345678", 1111));
ASSERT_FALSE(b.insert_card("1111222233334444", 1111));
}
catch(...){
ASSERT_TRUE(false);
}
}
TEST(test1, new_card){
Bankomat b("KravetsBank");
try {
b.add_account("1111222233334444", 1111, ("KravetsBank"));
b.add_account("1234567812345678", 1111, ("KravetsBank"));
b.insert_card("1111222233334444", 1111);
b.finish_work();
ASSERT_TRUE(b.insert_card("1234567812345678", 1111));
}
catch(...){
ASSERT_TRUE(false);
}
}
TEST(test1, incorrect_pass){
string exc;
Bankomat b("KravetsBank");
try{
b.add_account("1111222233334444", 1111, ("KravetsBank"));
ASSERT_FALSE(b.insert_card("1111222233334444", 1231));
}
catch(...){
ASSERT_TRUE(false);
}
}
TEST(test1, was_open){
Bankomat b("KravetsBank");
b.add_account("1111222233334444", 1111, ("KravetsBank"));
b.open_bankomat("2312");
ASSERT_FALSE(b.insert_card("1111222233334444", 1111));
}
TEST(test1, close_and_do){
Bankomat b("KravetsBank");
b.add_account("1111222233334444", 1111, ("KravetsBank"));
b.open_bankomat("2312");
b.add_account("1111111111111111", 1111, ("KravetsBank"));
b.close_bankomat();
ASSERT_TRUE(b.insert_card("1111111111111111", 1111));
}
TEST(test1, open_with_wrong_pass){
Bankomat b("KravetsBank");
ASSERT_FALSE(b.open_bankomat("1111"));
}