Add vote percentage tests.

GitOrigin-RevId: 421aa975080be0f1397357cba8abe088791474ff
This commit is contained in:
levlam 2019-04-23 17:06:53 +03:00
parent 482e4d7af6
commit 84e6e73abb
2 changed files with 3 additions and 1 deletions

View File

@ -95,7 +95,7 @@ class ConcurrentScheduler : private Scheduler::Callback {
unique_ptr<detail::Iocp> iocp_; unique_ptr<detail::Iocp> iocp_;
td::thread iocp_thread_; td::thread iocp_thread_;
#endif #endif
int extra_scheduler_; int32 extra_scheduler_;
void on_finish() override { void on_finish() override {
is_finished_.store(true, std::memory_order_relaxed); is_finished_.store(true, std::memory_order_relaxed);

View File

@ -45,6 +45,8 @@ TEST(Poll, get_vote_percentage) {
check_vote_percentage({1, 1, 1, 1, 1, 1, 2}, 8, {12, 12, 12, 12, 12, 12, 25}); check_vote_percentage({1, 1, 1, 1, 1, 1, 2}, 8, {12, 12, 12, 12, 12, 12, 25});
check_vote_percentage({1, 1, 1, 2, 2, 2, 3}, 12, {8, 8, 8, 17, 17, 17, 25}); check_vote_percentage({1, 1, 1, 2, 2, 2, 3}, 12, {8, 8, 8, 17, 17, 17, 25});
check_vote_percentage({0, 1, 1, 1, 2, 2, 2, 3}, 12, {0, 8, 8, 8, 17, 17, 17, 25}); check_vote_percentage({0, 1, 1, 1, 2, 2, 2, 3}, 12, {0, 8, 8, 8, 17, 17, 17, 25});
check_vote_percentage({1, 1, 1, 0}, 3, {33, 33, 33, 0});
check_vote_percentage({0, 1, 1, 1}, 3, {0, 33, 33, 33});
check_vote_percentage({9949, 9950, 9999}, 10000, {99, 100, 100}); check_vote_percentage({9949, 9950, 9999}, 10000, {99, 100, 100});
check_vote_percentage({1234, 2345, 3456, 2841}, 9876, check_vote_percentage({1234, 2345, 3456, 2841}, 9876,
{12 /* 12.49 */, 24 /* 23.74 */, 35 /* 34.99 */, 29 /* 28.76 */}); {12 /* 12.49 */, 24 /* 23.74 */, 35 /* 34.99 */, 29 /* 28.76 */});