Trie.cpp 903 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "pch.h"
  2. #include <Trie.h>
  3. #include <Text.h>
  4. #include "CppUnitTest.h"
  5. using namespace Microsoft::VisualStudio::CppUnitTestFramework;
  6. using namespace Framework;
  7. namespace FrameworkTests
  8. {
  9. TEST_CLASS (TrieTests)
  10. {
  11. public:
  12. TEST_METHOD (SimpleTrieTest)
  13. {
  14. Trie<int> trie;
  15. trie.set("test", 4, 1);
  16. int x = trie.get("test", 4);
  17. Assert::AreEqual(1, x, L"trie get returned invalid value");
  18. }
  19. TEST_METHOD (RCTrieTest)
  20. {
  21. RCTrie<Text> trie;
  22. trie.set("test", 4, new Text("test"));
  23. Text *t = trie.get("test", 4);
  24. Assert::AreEqual(
  25. t->getReferenceCount(), 2, L"RCTrie get did not increase reference count");
  26. Assert::IsTrue(t->istGleich("test"), L"RCTrie get returned invalid value");
  27. }
  28. };
  29. } // namespace FrameworkTests