-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOurTest.cpp
More file actions
58 lines (46 loc) · 1.63 KB
/
OurTest.cpp
File metadata and controls
58 lines (46 loc) · 1.63 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
/**
* A demo program for bull-pgia.
*
* @author Erel Segal-Halevi
* @since 2019-04
*/
#include <iostream>
using namespace std;
#include "play.hpp"
#include "DummyChoosers.hpp"
#include "DummyGuessers.hpp"
#include "SmartGuesser.hpp"
#include "badkan.hpp"
using namespace bullpgia;
int main() {
badkan::TestCase testcase;
int grade=0;
int signal = setjmp(badkan::longjmp_buffer);
if (signal == 0) {
// BASIC TESTS - DO NOT CHANGE
ConstantChooser c1234{"1234"}, c12345{"12345"}, c9999{"9999"};
ConstantGuesser g1234{"1234"}, g12345{"12345"}, g9999{"9999"};
testcase.setname("Calculate bull and pgia")
.CHECK_OUTPUT(calculateBullAndPgia("1234","1234"), "4,0") // 4 bull, 0 pgia
.CHECK_OUTPUT(calculateBullAndPgia("1234","4321"), "0,4") // 0 bull, 4 pgia
;
testcase.setname("Play with dummy choosers and guessers")
.CHECK_EQUAL(play(c1234, g1234, 4, 100), 1) // guesser wins in one turn.
.CHECK_EQUAL(play(c1234, g9999, 4, 100), 101) // guesser loses by running out of turns
.CHECK_EQUAL(play(c1234, g12345, 4, 100), 101) // guesser loses technically by making an illegal guess (too long).
.CHECK_EQUAL(play(c12345, g1234, 4, 100), 0) // chooser loses technically by choosing an illegal number (too long).
;
testcase.setname("Play with smart guesser");
RandomChooser randy;
SmartGuesser smarty;
for (uint i=0; i<100; ++i) {
testcase.CHECK_EQUAL(play(randy, smarty, 4, 200)<=100, true); // smarty should always win in at most 100 turns!
}
grade = testcase.grade();
} else {
testcase.print_signal(signal);
grade = 0;
}
cout << "Your grade is: " << grade << endl;
return 0;
}