#include <catch2/catch.hpp>
#include "tdigest.hpp"
#include "test_allocator.hpp"
namespace datasketches {
using alloc_d = test_allocator<double>;
using tdigest_d = tdigest<double, alloc_d>;
TEST_CASE("tdigest custom allocator", "[tdigest]") {
test_allocator_total_bytes = 0;
test_allocator_net_allocations = 0;
{
tdigest_d td(100, alloc_d(0));
for (int i = 0; i < 10000; ++i) td.update(static_cast<double>(i));
REQUIRE(test_allocator_total_bytes != 0);
REQUIRE(test_allocator_net_allocations != 0);
}
REQUIRE(test_allocator_total_bytes == 0);
REQUIRE(test_allocator_net_allocations == 0);
}
}