<commit_before>/**
 *  @autor tekatod
 *  @date 9/1/16
 */
#include <iostream>
#include <string>
#include <gtest/gtest.h>
#include "rrc/core/MetaTable.h"
#include "Message.pb.h"

TEST(MetaTableTest, RegisterTest) {
    rrc::MetaTable mtbl;
    EXPECT_TRUE(mtbl.registerTypeId<testmessages::TestMessage>(1u));
}

TEST(MetaTableTest, ReservedIdTest) {
    rrc::MetaTable mtbl;
    mtbl.registerTypeId<testmessages::TestMessage>(1u);
    EXPECT_TRUE(mtbl.isIdReserved(1u));
}

TEST(MetaTableTest, GetTypeIdTest1) {
    rrc::MetaTable mtbl;
    mtbl.registerTypeId<testmessages::TestMessage>(1);
    EXPECT_EQ(mtbl.getTypeId<testmessages::TestMessage>(), 1u);
}

TEST(MetaTableTest, GetTypeIdTest2) {
    rrc::MetaTable metaTable;
    metaTable.registerTypeId<testmessages::TestMessage>(1);
    metaTable.registerTypeId<testmessages::TestMessageContainer>(2);
    EXPECT_EQ(metaTable.getTypeId<testmessages::TestMessage>(), 1u);
    EXPECT_EQ(metaTable.getTypeId<testmessages::TestMessageContainer>(), 2u);
}

TEST(MetaTableTest, FreeIdTest) {
    rrc::MetaTable mtbl;
    mtbl.registerTypeId<testmessages::TestMessage>(1u);
    EXPECT_TRUE(mtbl.freeTypeId(1));
}

TEST(MetaTableTest, FreeIdReservedTest) {
    rrc::MetaTable mtbl;
    mtbl.registerTypeId<testmessages::TestMessage>(1u);
    mtbl.freeTypeId(1);
    EXPECT_FALSE(mtbl.isIdReserved(1));
}

TEST(MetaTableTest, ReplaceRegisteredId) {
    rrc::MetaTable metaTable;
    metaTable.registerTypeId<testmessages::TestMessage>(1u);
    EXPECT_FALSE(metaTable.registerTypeId<testmessages::TestMessageContainer>(1u));
}

TEST(MetaTableTest, GetUnregisteredId) {
    rrc::MetaTable metaTable;
    EXPECT_EQ(metaTable.getTypeId<testmessages::TestMessage>(),
              rrc::MetaTable::UNKNOWN_TYPE_ID);
}<commit_msg>Test message factory in metatable<commit_after>/**
 *  @autor tekatod
 *  @date 9/1/16
 */
#include <iostream>
#include <string>
#include <gtest/gtest.h>
#include "rrc/core/MetaTable.h"
#include "Message.pb.h"

using namespace rrc;

TEST(MetaTableTest, RegisterTest) {
    MetaTable mtbl;
    EXPECT_TRUE(mtbl.registerTypeId<testmessages::TestMessage>(1u));
}

TEST(MetaTableTest, ReservedIdTest) {
    MetaTable mtbl;
    mtbl.registerTypeId<testmessages::TestMessage>(1u);
    EXPECT_TRUE(mtbl.isIdReserved(1u));
}

TEST(MetaTableTest, GetTypeIdTest1) {
    MetaTable mtbl;
    mtbl.registerTypeId<testmessages::TestMessage>(1);
    EXPECT_EQ(mtbl.getTypeId<testmessages::TestMessage>(), 1u);
}

TEST(MetaTableTest, GetTypeIdTest2) {
    MetaTable metaTable;
    metaTable.registerTypeId<testmessages::TestMessage>(1);
    metaTable.registerTypeId<testmessages::TestMessageContainer>(2);
    EXPECT_EQ(metaTable.getTypeId<testmessages::TestMessage>(), 1u);
    EXPECT_EQ(metaTable.getTypeId<testmessages::TestMessageContainer>(), 2u);
}

TEST(MetaTableTest, FreeIdTest) {
    MetaTable mtbl;
    mtbl.registerTypeId<testmessages::TestMessage>(1u);
    EXPECT_TRUE(mtbl.freeTypeId(1));
}

TEST(MetaTableTest, FreeIdReservedTest) {
    MetaTable mtbl;
    mtbl.registerTypeId<testmessages::TestMessage>(1u);
    mtbl.freeTypeId(1);
    EXPECT_FALSE(mtbl.isIdReserved(1));
}

TEST(MetaTableTest, ReplaceRegisteredId) {
    MetaTable metaTable;
    metaTable.registerTypeId<testmessages::TestMessage>(1u);
    EXPECT_FALSE(metaTable.registerTypeId<testmessages::TestMessageContainer>(1u));
}

TEST(MetaTableTest, GetUnregisteredId) {
    MetaTable metaTable;
    EXPECT_EQ(metaTable.getTypeId<testmessages::TestMessage>(),
              MetaTable::UNKNOWN_TYPE_ID);
}

TEST(MetaTableTest, MessageFactoryTest) {
    MetaTable metaTable;
    metaTable.registerTypeId<testmessages::TestMessage>(1u);
    MessageFactoryPtr messageFactoryPtr = metaTable.getMessageFactory(1u);
    ASSERT_NE(messageFactoryPtr, nullptr);
    EXPECT_NE(messageFactoryPtr->createMessage(), nullptr);
    EXPECT_EQ(metaTable.getMessageFactory(2u), nullptr);
}
{'fraction_non_alphanumeric': 0.13157219799948705, 'fraction_numerical': 0.01205437291613234, 'mean_word_length': 6.262569832402234, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 37, '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': '6690500', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1346, 'n_words': 157}