MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/lib/gtl/compactptrset_test.cc:34–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34TEST(CompactPointerSetTest, Simple) {
35 // Make some aligned and some unaligned pointers.
36 string data = "ABCDEFG";
37 const char* a = &data[0];
38 const char* b = &data[1];
39 const char* c = &data[2];
40 const char* d = &data[3];
41 const char* e = &data[4];
42 const char* f = &data[5];
43 const char* g = &data[6];
44 for (const auto& list : std::vector<std::vector<const char*>>({{
45 {}, // Empty
46 {a}, // Aligned singleton
47 {b}, // Unaligned singleton
48 {nullptr}, // Test insertion of nullptr
49 {a, b, c, d, e, f, g}, // Many
50 }})) {
51 LOG(INFO) << list.size();
52
53 // Test insert along with accessors.
54 StringSet set;
55 ASSERT_TRUE(set.empty());
56 for (auto p : list) {
57 ASSERT_EQ(set.count(p), 0);
58 ASSERT_TRUE(set.insert(p).second);
59 ASSERT_EQ(set.count(p), 1);
60 ASSERT_TRUE(set.find(p) != set.end());
61 }
62 ASSERT_EQ(set.size(), list.size());
63
64 ASSERT_EQ(SortedContents(set), list);
65
66 // Test copy constructor.
67 {
68 StringSet set2(set);
69 ASSERT_EQ(SortedContents(set2), list);
70 }
71
72 // Test assignment/copying into a destination with different
73 // initial elements.
74 for (const auto& initial : std::vector<std::vector<const char*>>({{
75 {}, // Empty
76 {a}, // Aligned singleton
77 {b}, // Unaligned singleton
78 {nullptr}, // Test insertion of nullptr
79 {a, b, c, d}, // Many
80 }})) {
81 StringSet dst;
82 for (auto p : initial) {
83 dst.insert(p);
84 }
85 ASSERT_EQ(dst.size(), initial.size());
86 dst = set;
87 ASSERT_EQ(SortedContents(dst), list);
88 dst.clear();
89 ASSERT_EQ(dst.size(), 0);
90 }
91

Callers

nothing calls this directly

Calls 9

SortedContentsFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45
countMethod · 0.45
insertMethod · 0.45
findMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected