| 60 | } |
| 61 | |
| 62 | void |
| 63 | testWString() |
| 64 | { |
| 65 | WStringTable st; |
| 66 | |
| 67 | size_t size = st.size(); |
| 68 | assert(size == 0); |
| 69 | assert(!st.hasString(L"foo")); |
| 70 | |
| 71 | StringTableIndex index = st.intern(L"foo"); |
| 72 | assert(index == st.lookup(L"foo")); |
| 73 | assert(st.lookup(index) == L"foo"); |
| 74 | assert(st.hasString(L"foo")); |
| 75 | |
| 76 | size = st.size(); |
| 77 | assert(size == 1); |
| 78 | |
| 79 | bool thrown = false; |
| 80 | try { |
| 81 | index = st.lookup(L"bar"); |
| 82 | } catch (std::exception &e) { |
| 83 | thrown = true; |
| 84 | } |
| 85 | assert (thrown); |
| 86 | |
| 87 | thrown = false; |
| 88 | try { |
| 89 | std::wstring s = st.lookup(StringTableIndex(1)); |
| 90 | } catch (std::exception &e) { |
| 91 | thrown = true; |
| 92 | } |
| 93 | assert (thrown); |
| 94 | |
| 95 | assert(!st.hasString(L"bar")); |
| 96 | |
| 97 | index = st.intern(L"bar"); |
| 98 | assert(index == st.lookup(L"bar")); |
| 99 | assert(st.lookup(index) == L"bar"); |
| 100 | assert(0 == st.lookup(L"foo").index()); |
| 101 | assert(st.lookup(StringTableIndex(0)) == L"foo"); |
| 102 | assert(st.hasString(L"bar")); |
| 103 | } |
| 104 | |
| 105 | } // namespace |
| 106 |
no test coverage detected