1 #include "../../src/time.h"
2 #include "gtest/gtest.h"
4 TEST(TimeTest
, Constructor
)
9 const int time
= 5 * 60 * 100; // 5 minutes in centiseconds
10 EXPECT_EQ(time
/ moves
, t1
.allocated());
12 // Explicit constructor
14 EXPECT_EQ(time
/ moves
, t2
.allocated());
17 TEST(TimeTest
, Thinking
)
19 const int level_moves
= 40;
20 const int level_time
= 5 * 60 * 100; // 5 minutes in centiseconds
21 const int time_per_move
= level_time
/ level_moves
;
22 Time
t(level_moves
, level_time
);
24 int time
= level_time
;
25 for (int ply
= 0; ply
< 200; ++ply
) {
26 t
.set_remaining(time
);
27 t
.start_thinking(ply
);
28 EXPECT_EQ(time_per_move
, t
.allocated());
31 if (((ply
/ 2) + 1) % level_moves
== 0) {
34 time
-= time_per_move
;
40 // TODO: Add polling and abort tests