<commit_before>#include "gtest/gtest.h"
#include "c7a/data/data_manager.hpp"

using namespace c7a::data;

TEST(DataManager, GetLocalBlock_FailsIfNotFound) {
    DataManager manager;
    ASSERT_ANY_THROW(manager.GetLocalBlocks<int>(0));
}

TEST(DataManager, GetLocalEmitter_FailsIfNotFound) {
    DataManager manager;
    ASSERT_ANY_THROW(manager.GetLocalEmitter<int>(0));
}

TEST(DataManager, GetLocalEmitter_CanCallEmitter) {
    DataManager manager;
    auto e = manager.GetLocalEmitter<int>(manager.AllocateDIA());
    ASSERT_NO_THROW(e(123));
}

TEST(DataManager, EmittAndIterate_CorrectOrder) {
    DataManager manager;
    auto id = manager.AllocateDIA();
    auto emitFn = manager.GetLocalEmitter<int>(id);
    emitFn(123);
    emitFn(22);
    auto it = manager.GetLocalBlocks<int>(id);
    ASSERT_EQ(123, it.Next());
    ASSERT_EQ(22, it.Next());
}

TEST(DataManager, EmittAndIterate_ConcurrentAccess) {
    DataManager manager;
    auto id = manager.AllocateDIA();
    auto emitFn = manager.GetLocalEmitter<int>(id);<commit_msg>use test fixture for DataManager tests<commit_after>#include "gtest/gtest.h"
#include "c7a/data/data_manager.hpp"

using namespace c7a::data;

struct DataManagerFixture : public ::testing::Test {
    DataManager manager;
    DIAId id = manager.AllocateDIA();
};

TEST_F(DataManagerFixture, GetLocalBlock_FailsIfNotFound) {
    ASSERT_ANY_THROW(manager.GetLocalBlocks<int>(999));
}

TEST_F(DataManagerFixture, GetLocalEmitter_FailsIfNotFound) {
    ASSERT_ANY_THROW(manager.GetLocalEmitter<int>(23));
}

TEST_F(DataManagerFixture, GetLocalEmitter_CanCallEmitter) {
    auto e = manager.GetLocalEmitter<int>(manager.AllocateDIA());
    ASSERT_NO_THROW(e(123));
}

TEST_F(DataManagerFixture, EmittAndIterate_CorrectOrder) {
    auto id = manager.AllocateDIA();
    auto emitFn = manager.GetLocalEmitter<int>(id);
    emitFn(123);
    emitFn(22);
    auto it = manager.GetLocalBlocks<int>(id);
    ASSERT_EQ(123, it.Next());
    ASSERT_EQ(22, it.Next());
}

TEST_F(DataManagerFixture, EmittAndIterate_ConcurrentAccess) {
    auto id = manager.AllocateDIA();
    auto emitFn = manager.GetLocalEmitter<int>(id);
{'fraction_non_alphanumeric': 0.12371615312791784, 'fraction_numerical': 0.01727357609710551, 'mean_word_length': 5.634674922600619, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '1986693', 'n_tokens_mistral': 750, 'n_tokens_neox': 742, 'n_words': 111}