<commit_before>#include <catch.hpp>
#include "../coap/decoder-subject.hpp"
#include "test-data.h"

using namespace moducom::coap;

// +++ just to test compilation, eliminate once decent unit tests for
// DecoderSubjectBase is in place
static IncomingContext test_ctx;
static DecoderSubjectBase<experimental::ContextDispatcherHandler> test(test_ctx);
// ---

// FIX: putting this above causes compilation issues, clean that up
#include "test-observer.h"

using namespace moducom::pipeline;

TEST_CASE("CoAP decoder subject tests", "[coap-decoder-subject]")
{
    SECTION("16 bit delta: ContextDispatcherHandler")
    {
        MemoryChunk::readonly_t chunk(buffer_16bit_delta);
        test.dispatch(chunk);

        REQUIRE(test_ctx.have_header());
        REQUIRE(test_ctx.header().is_request());
    }
    SECTION("16 bit detla: Buffer16BitDeltaObserver")
    {
        IncomingContext test_ctx2;
        DecoderSubjectBase<Buffer16BitDeltaObserver> test2(test_ctx2);
        MemoryChunk::readonly_t chunk(buffer_16bit_delta);
        test2.dispatch(chunk);
    }
    SECTION("16 bit detla: Buffer16BitDeltaObserver&")
    {
        Buffer16BitDeltaObserver observer;
        DecoderSubjectBase<IDispatcherHandler&> test2(observer);
        MemoryChunk::readonly_t chunk(buffer_16bit_delta);
        test2.dispatch(chunk);
    }
    SECTION("payload only")
    {
        MemoryChunk::readonly_t chunk(buffer_payload_only);
        test.dispatch(chunk);

        REQUIRE(test_ctx.have_header());
        REQUIRE(test_ctx.header().is_request());
    }
}
<commit_msg>Neat that we can pop in IMessageObserver& here<commit_after>#include <catch.hpp>
#include "../coap/decoder-subject.hpp"
#include "test-data.h"

using namespace moducom::coap;

// +++ just to test compilation, eliminate once decent unit tests for
// DecoderSubjectBase is in place
static IncomingContext test_ctx;
static DecoderSubjectBase<experimental::ContextDispatcherHandler> test(test_ctx);
// ---

// FIX: putting this above causes compilation issues, clean that up
#include "test-observer.h"

using namespace moducom::pipeline;

TEST_CASE("CoAP decoder subject tests", "[coap-decoder-subject]")
{
    SECTION("16 bit delta: ContextDispatcherHandler")
    {
        MemoryChunk::readonly_t chunk(buffer_16bit_delta);
        test.dispatch(chunk);

        REQUIRE(test_ctx.have_header());
        REQUIRE(test_ctx.header().is_request());
    }
    SECTION("16 bit detla: Buffer16BitDeltaObserver")
    {
        IncomingContext test_ctx2;
        DecoderSubjectBase<Buffer16BitDeltaObserver> test2(test_ctx2);
        MemoryChunk::readonly_t chunk(buffer_16bit_delta);
        test2.dispatch(chunk);
    }
    SECTION("16 bit detla: Buffer16BitDeltaObserver&")
    {
        Buffer16BitDeltaObserver observer;
        DecoderSubjectBase<IMessageObserver&> test2(observer);
        MemoryChunk::readonly_t chunk(buffer_16bit_delta);
        test2.dispatch(chunk);
    }
    SECTION("payload only")
    {
        MemoryChunk::readonly_t chunk(buffer_payload_only);
        test.dispatch(chunk);

        REQUIRE(test_ctx.have_header());
        REQUIRE(test_ctx.header().is_request());
    }
}

{'fraction_non_alphanumeric': 0.11223521972810623, 'fraction_numerical': 0.016440088523553588, 'mean_word_length': 3.882716049382716, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3292187', 'n_tokens_mistral': 994, 'n_tokens_neox': 934, 'n_words': 181}