MCPcopy Create free account
hub / github.com/catboost/catboost / Y_UNIT_TEST

Function Y_UNIT_TEST

util/generic/mapfindptr_ut.cpp:13–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11 struct TTestMap: std::map<int, TString>, TMapOps<TTestMap> {};
12
13 Y_UNIT_TEST(TestDerivedClass) {
14 TTestMap a;
15
16 a[42] = "cat";
17 UNIT_ASSERT(a.FindPtr(42));
18 UNIT_ASSERT_EQUAL(*a.FindPtr(42), "cat");
19 UNIT_ASSERT_EQUAL(a.FindPtr(0), nullptr);
20
21 // test mutation
22 if (TString* p = a.FindPtr(42)) {
23 *p = "dog";
24 }
25 UNIT_ASSERT(a.FindPtr(42));
26 UNIT_ASSERT_EQUAL(*a.FindPtr(42), "dog");
27
28 // test const-overloaded functions too
29 const TTestMap& b = a;
30 UNIT_ASSERT(b.FindPtr(42) && *b.FindPtr(42) == "dog");
31 UNIT_ASSERT_EQUAL(b.FindPtr(0), nullptr);
32
33 UNIT_ASSERT_STRINGS_EQUAL(b.Value(42, "cat"), "dog");
34 UNIT_ASSERT_STRINGS_EQUAL(b.Value(0, "alien"), "alien");
35 }
36
37 Y_UNIT_TEST(TestTemplateFind) {
38 THashMap<TString, int> m;

Callers

nothing calls this directly

Calls 2

FindPtrMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected