MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/Imath / testWString

Function testWString

src/python/PyImathTest/testStringTable.cpp:62–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62void
63testWString()
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

Callers 1

testStringTableFunction · 0.85

Calls 6

StringTableIndexClass · 0.85
hasStringMethod · 0.80
internMethod · 0.80
lookupMethod · 0.80
indexMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected