mirror of
https://github.com/transmission/transmission
synced 2024-12-27 18:18:10 +00:00
5e769fbc55
This gives more flexibility on the size of the count bins, so we can save space on smaller counts
24 lines
713 B
C++
24 lines
713 B
C++
// This file Copyright (C) 2013-2022 Mnemosyne LLC.
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0), GPLv3 (SPDX: GPL-3.0),
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
// License text can be found in the licenses/ folder.
|
|
|
|
#include "transmission.h"
|
|
#include "history.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
TEST(History, recentHistory)
|
|
{
|
|
auto h = tr_recentHistory<size_t, 60>{};
|
|
|
|
h.add(10000, 1);
|
|
EXPECT_EQ(0U, h.count(12000, 1000));
|
|
EXPECT_EQ(1U, h.count(12000, 3000));
|
|
EXPECT_EQ(1U, h.count(12000, 5000));
|
|
h.add(20000, 1);
|
|
EXPECT_EQ(0U, h.count(22000, 1000));
|
|
EXPECT_EQ(1U, h.count(22000, 3000));
|
|
EXPECT_EQ(2U, h.count(22000, 15000));
|
|
EXPECT_EQ(2U, h.count(22000, 20000));
|
|
}
|