<commit_before>#include "includes.h"
#include "spdlog/sinks/dup_filter_sink.h"
#include "test_sink.h"

using namespace spdlog;
using namespace spdlog::sinks;


TEST_CASE("dup_filter_test1", "[dup_filter_sink]")
{
    dup_filter_sink_st dup_sink {std::chrono::seconds{5}};
    auto test_sink = std::make_shared<test_sink_mt>();
    dup_sink.add_sink(test_sink);

    for(int i = 0; i < 10; i++)
    {
        dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
    }

    REQUIRE(test_sink->msg_counter() == 1);
}

TEST_CASE("dup_filter_test2", "[dup_filter_sink]")
{
    dup_filter_sink_st dup_sink {std::chrono::seconds{0}};
    auto test_sink = std::make_shared<test_sink_mt>();
    dup_sink.add_sink(test_sink);

    for(int i = 0; i < 10; i++)
    {
        dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
    }

    REQUIRE(test_sink->msg_counter() == 10);
}

TEST_CASE("dup_filter_test3", "[dup_filter_sink]")
{
    dup_filter_sink_st dup_sink {std::chrono::seconds{0}};
    auto test_sink = std::make_shared<test_sink_mt>();
    dup_sink.add_sink(test_sink);

    for(int i = 0; i < 10; i++)
    {
        dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
        dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message2"});
    }

    REQUIRE(test_sink->msg_counter() == 20);
}

TEST_CASE("dup_filter_test4", "[dup_filter_sink]")
{
    dup_filter_sink_st dup_sink {std::chrono::milliseconds{10}};
    auto test_sink = std::make_shared<test_sink_mt>();
    dup_sink.add_sink(test_sink);

    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message"});
    std::this_thread::sleep_for(std::chrono::milliseconds(50));
    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message"});
    REQUIRE(test_sink->msg_counter() == 2);
}

TEST_CASE("dup_filter_test5", "[dup_filter_sink]")
{
    dup_filter_sink_st dup_sink {std::chrono::seconds{5}};
    auto test_sink = std::make_shared<test_sink_mt>();
    dup_sink.add_sink(test_sink);

    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message2"});

    REQUIRE(test_sink->msg_counter() == 3); // skip 2 messages but log the "skipped.." message before message2
}
<commit_msg>Added tests for dup_filter sink<commit_after>#include "includes.h"
#include "spdlog/sinks/dup_filter_sink.h"
#include "test_sink.h"

using namespace spdlog;
using namespace spdlog::sinks;


TEST_CASE("dup_filter_test1", "[dup_filter_sink]")
{
    dup_filter_sink_st dup_sink {std::chrono::seconds{5}};
    auto test_sink = std::make_shared<test_sink_mt>();
    dup_sink.add_sink(test_sink);

    for(int i = 0; i < 10; i++)
    {
        dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
    }

    REQUIRE(test_sink->msg_counter() == 1);
}

TEST_CASE("dup_filter_test2", "[dup_filter_sink]")
{
    dup_filter_sink_st dup_sink {std::chrono::seconds{0}};
    auto test_sink = std::make_shared<test_sink_mt>();
    dup_sink.add_sink(test_sink);

    for(int i = 0; i < 10; i++)
    {
        dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
    }

    REQUIRE(test_sink->msg_counter() == 10);
}

TEST_CASE("dup_filter_test3", "[dup_filter_sink]")
{
    dup_filter_sink_st dup_sink {std::chrono::seconds{0}};
    auto test_sink = std::make_shared<test_sink_mt>();
    dup_sink.add_sink(test_sink);

    for(int i = 0; i < 10; i++)
    {
        dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
        dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message2"});
    }

    REQUIRE(test_sink->msg_counter() == 20);
}

TEST_CASE("dup_filter_test4", "[dup_filter_sink]")
{
    dup_filter_sink_mt dup_sink {std::chrono::milliseconds{10}};
    auto test_sink = std::make_shared<test_sink_mt>();
    dup_sink.add_sink(test_sink);

    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message"});
    std::this_thread::sleep_for(std::chrono::milliseconds(50));
    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message"});
    REQUIRE(test_sink->msg_counter() == 2);
}

TEST_CASE("dup_filter_test5", "[dup_filter_sink]")
{
    dup_filter_sink_mt dup_sink {std::chrono::seconds{5}};
    auto test_sink = std::make_shared<test_sink_mt>();
    dup_sink.add_sink(test_sink);

    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message1"});
    dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message2"});

    REQUIRE(test_sink->msg_counter() == 3); // skip 2 messages but log the "skipped.." message before message2
}

{'fraction_non_alphanumeric': 0.18525741029641185, 'fraction_numerical': 0.015210608424336974, 'mean_word_length': 5.704575163398693, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4089658', 'n_tokens_mistral': 2155, 'n_tokens_neox': 2064, 'n_words': 256}