-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard_public_test.cpp
64 lines (53 loc) · 1.83 KB
/
Card_public_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
#include <sstream>
#include "unit_test_framework.hpp"
#include "Card.hpp"
using namespace std;
// THESE TEST CASES WILL ONLY TELL YOU IF YOUR CODE COMPILES.
// YOU NEED TO WRITE YOUR OWN COMPREHENSIVE TEST CASES IN Card_tests.cpp
TEST(test_card_suit_and_rank) {
Card two_spades = Card();
ASSERT_EQUAL(two_spades.get_rank(), TWO);
ASSERT_EQUAL(two_spades.get_suit(), SPADES);
Card three_spades = Card(THREE, SPADES);
ASSERT_EQUAL(three_spades.get_rank(), THREE);
ASSERT_EQUAL(three_spades.get_suit(), SPADES);
ASSERT_EQUAL(three_spades.get_suit(CLUBS), SPADES);
}
TEST(test_card_type) {
Card three_spades = Card(THREE, SPADES);
ASSERT_FALSE(three_spades.is_face_or_ace());
ASSERT_FALSE(three_spades.is_right_bower(CLUBS));
ASSERT_FALSE(three_spades.is_left_bower(CLUBS));
ASSERT_FALSE(three_spades.is_trump(CLUBS));
}
TEST(test_card_self_comparison) {
Card three_spades = Card(THREE, SPADES);
ASSERT_FALSE(three_spades < three_spades);
ASSERT_TRUE(three_spades <= three_spades);
ASSERT_FALSE(three_spades > three_spades);
ASSERT_TRUE(three_spades >= three_spades);
ASSERT_TRUE(three_spades == three_spades);
ASSERT_FALSE(three_spades != three_spades);
}
TEST(test_Suit_next) {
ASSERT_EQUAL(Suit_next(CLUBS), SPADES);
}
TEST(test_Card_less_self) {
Card three_spades = Card(THREE, SPADES);
ASSERT_FALSE(Card_less(three_spades, three_spades, CLUBS));
ASSERT_FALSE(Card_less(three_spades, three_spades, three_spades,
CLUBS));
}
TEST(test_card_insertion) {
Card three_spades = Card(THREE, SPADES);
ostringstream oss;
oss << three_spades;
ASSERT_EQUAL(oss.str(), "Three of Spades");
}
TEST(test_card_extraction) {
istringstream iss("Three of Spades");
Card c;
iss >> c;
ASSERT_EQUAL(c, Card(THREE, SPADES));
}
TEST_MAIN()