Changeset View
Changeset View
Standalone View
Standalone View
src/test/timedata_tests.cpp
// Copyright (c) 2011-2019 The Bitcoin Core developers | // Copyright (c) 2011-2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
// | // | ||||
#include <timedata.h> | #include <timedata.h> | ||||
#include <netaddress.h> | #include <netaddress.h> | ||||
#include <noui.h> | #include <noui.h> | ||||
#include <test/util/logging.h> | #include <test/util/logging.h> | ||||
#include <util/string.h> | |||||
#include <warnings.h> | #include <warnings.h> | ||||
#include <test/util/setup_common.h> | #include <test/util/setup_common.h> | ||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
#include <string> | #include <string> | ||||
Show All 22 Lines | BOOST_AUTO_TEST_CASE(util_MedianFilter) { | ||||
filter.input(0); // [0 3 7 18 30] | filter.input(0); // [0 3 7 18 30] | ||||
BOOST_CHECK_EQUAL(filter.median(), 7); | BOOST_CHECK_EQUAL(filter.median(), 7); | ||||
} | } | ||||
static void MultiAddTimeData(int n, int64_t offset) { | static void MultiAddTimeData(int n, int64_t offset) { | ||||
static int cnt = 0; | static int cnt = 0; | ||||
for (int i = 0; i < n; ++i) { | for (int i = 0; i < n; ++i) { | ||||
CNetAddr addr; | CNetAddr addr; | ||||
addr.SetInternal(std::to_string(++cnt)); | addr.SetInternal(ToString(++cnt)); | ||||
AddTimeData(addr, offset); | AddTimeData(addr, offset); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(addtimedata) { | BOOST_AUTO_TEST_CASE(addtimedata) { | ||||
BOOST_CHECK_EQUAL(GetTimeOffset(), 0); | BOOST_CHECK_EQUAL(GetTimeOffset(), 0); | ||||
// Part 1: Add large offsets to test a warning message that our clock may be | // Part 1: Add large offsets to test a warning message that our clock may be | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |