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

Function testString

src/python/PyImathTest/testStringTable.cpp:19–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17namespace {
18
19void
20testString()
21{
22 StringTable st;
23
24 size_t size = st.size();
25 assert(size == 0);
26 assert(!st.hasString("foo"));
27
28 StringTableIndex index = st.intern("foo");
29 assert(index == st.lookup("foo"));
30 assert(st.lookup(index) == "foo");
31 assert(st.hasString("foo"));
32
33 size = st.size();
34 assert(size == 1);
35
36 bool thrown = false;
37 try {
38 index = st.lookup("bar");
39 } catch (std::exception &e) {
40 thrown = true;
41 }
42 assert (thrown);
43
44 thrown = false;
45 try {
46 std::string s = st.lookup(StringTableIndex(1));
47 } catch (std::exception &e) {
48 thrown = true;
49 }
50 assert (thrown);
51
52 assert(!st.hasString("bar"));
53
54 index = st.intern("bar");
55 assert(index == st.lookup("bar"));
56 assert(st.lookup(index) == "bar");
57 assert(0 == st.lookup("foo").index());
58 assert(st.lookup(StringTableIndex(0)) == "foo");
59 assert(st.hasString("bar"));
60}
61
62void
63testWString()

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