#include "pch.h"

#include <Trie.h>
#include <Text.h>

#include "CppUnitTest.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace Framework;

namespace FrameworkTests
{
    TEST_CLASS (TrieTests)
    {
    public:
        TEST_METHOD (SimpleTrieTest)
        {
            Trie<int> trie;
            trie.set("test", 4, 1);
            int x = trie.get("test", 4);
            Assert::AreEqual(1, x, L"trie get returned invalid value");
        }

        TEST_METHOD (RCTrieTest)
        {
            RCTrie<Text> trie;
            trie.set("test", 4, new Text("test"));
            Text *t = trie.get("test", 4);
            Assert::AreEqual(
                t->getReferenceCount(), 2, L"RCTrie get did not increase reference count");
            Assert::IsTrue(t->istGleich("test"), L"RCTrie get returned invalid value");
        }
    };
} // namespace FrameworkTests