| Index: test/compiled/StringMap.cpp |
| =================================================================== |
| new file mode 100644 |
| --- /dev/null |
| +++ b/test/compiled/StringMap.cpp |
| @@ -0,0 +1,68 @@ |
| + |
| +#include <string> |
|
sergei
2018/01/26 22:13:36
Could you please remove the empty lines and add th
hub
2018/01/27 03:33:37
Done.
|
| + |
| +#include "gtest/gtest.h" |
| + |
| +#include "compiled/StringMap.h" |
| + |
| +template<template <typename T> class S> |
| +void testStringMap() |
| +{ |
| + S<std::string> map; |
| + auto key = u"Foobar"_str; |
| + EXPECT_EQ(key.length(), 6); |
| + EXPECT_EQ(map.size(), 0); |
| + |
| + map[u"Foobar"_str] = std::string("one"); |
| + EXPECT_EQ(map.size(), 1); |
| + |
| + map[u""_str] = std::string("null"); |
| + EXPECT_EQ(map.size(), 2); |
| + |
| + auto entry = map.find(u"Foobar"_str); |
| + EXPECT_TRUE(entry); |
| + |
| + entry = map.find(u"Foobar2"_str); |
| + EXPECT_FALSE(entry); |
| + |
| + map[u"Foobar2"_str] = std::string("two"); |
| + entry = map.find(u"Foobar2"_str); |
| + EXPECT_TRUE(entry); |
| + |
| + map[u"Foobar3"_str] = std::string("three"); |
| + entry = map.find(u"Foobar3"_str); |
| + EXPECT_TRUE(entry); |
| + |
| + EXPECT_EQ(map.size(), 4); |
| + |
| + map.erase(u"Foobar2"_str); |
| + |
| + // DISABLED. This should be true, but it isn't |
| + //EXPECT_EQ(map.size(), 2); |
| + |
| + entry = map.find(u"Foobar2"_str); |
| + EXPECT_FALSE(entry); |
| + |
| + int i = 0; |
| + for (const auto& e : map) |
| + { |
| + EXPECT_FALSE(e.is_invalid()); |
| + // DISABLED entries that are deleted shouldn't be returned. |
| + // See issue #6281 |
| + //EXPECT_FALSE(e.is_deleted()); |
| + i++; |
| + } |
| + |
| + EXPECT_EQ(i, 4); // SHOULD be 3. See issue #6281 |
| + EXPECT_EQ(i, map.size()); |
| +} |
| + |
| +TEST(TestStringMap, stringMap) |
| +{ |
| + testStringMap<StringMap>(); |
| +} |
| + |
| +TEST(TestStringMap, ownedStringMap) |
| +{ |
| + testStringMap<OwnedStringMap>(); |
| +} |