2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright (C) 2013-2022 Mnemosyne LLC.
|
2022-08-08 18:05:39 +00:00
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
2022-01-20 18:27:56 +00:00
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2020-08-11 18:11:55 +00:00
|
|
|
|
2023-01-02 16:23:51 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
|
|
|
#include <libtransmission/history.h>
|
2020-08-11 18:11:55 +00:00
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
TEST(History, recentHistory)
|
|
|
|
{
|
2022-04-28 15:52:26 +00:00
|
|
|
auto h = tr_recentHistory<size_t, 60>{};
|
2020-08-11 18:11:55 +00:00
|
|
|
|
2021-10-07 13:33:55 +00:00
|
|
|
h.add(10000, 1);
|
2022-04-02 14:06:02 +00:00
|
|
|
EXPECT_EQ(0U, h.count(12000, 1000));
|
|
|
|
EXPECT_EQ(1U, h.count(12000, 3000));
|
|
|
|
EXPECT_EQ(1U, h.count(12000, 5000));
|
2021-10-07 13:33:55 +00:00
|
|
|
h.add(20000, 1);
|
2022-04-02 14:06:02 +00:00
|
|
|
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));
|
2020-08-11 18:11:55 +00:00
|
|
|
}
|