MCPcopy Create free account
hub / github.com/apache/qpid-proton / null_test

Function null_test

cpp/src/value_test.cpp:79–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void null_test() {
80 proton::null n;
81 ASSERT_EQUAL("null", to_string(n));
82
83 std::vector<proton::value> nulls(2, n);
84 ASSERT_EQUAL("[null, null]", to_string(nulls));
85
86 std::vector<proton::null> nulls1(2, n);
87 ASSERT_EQUAL("@PN_NULL[null, null]", to_string(nulls1));
88
89 std::vector<proton::value> vs;
90 vs.push_back(n);
91 vs.push_back(nulls);
92 vs.push_back(nulls1);
93 ASSERT_EQUAL("[null, [null, null], @PN_NULL[null, null]]", to_string(vs));
94
95 std::map<proton::value, proton::value> vm;
96 vm[n] = 1;
97 vm[nulls1] = 2;
98 vm[nulls] = 3;
99 // Different types compare by type-id, so NULL < ARRAY < LIST
100 ASSERT_EQUAL("{null=1, @PN_NULL[null, null]=2, [null, null]=3}", to_string(vm));
101
102 std::map<proton::scalar, proton::scalar> vm2;
103 vm2[n] = 1; // Different types compare by type-id, NULL is smallest
104 vm2[2] = n;
105 ASSERT_EQUAL("{null=1, 2=null}", to_string(vm2));
106
107 proton::value nn = nullptr;
108 ASSERT(n == nn); // Don't use ASSERT_EQUAL, it will try to print
109 ASSERT_EQUAL("null", to_string(nn));
110 std::vector<std::nullptr_t> nulls2 {nullptr, nullptr};
111 ASSERT_EQUAL("@PN_NULL[null, null]", to_string(nulls2));
112 std::map<proton::scalar, proton::scalar> m {{nullptr, nullptr}};
113 ASSERT_EQUAL("{null=null}", to_string(m));
114 std::map<proton::value, proton::value> m2 {{nullptr, nullptr}};
115 ASSERT_EQUAL("{null=null}", to_string(m2));
116}
117
118}
119

Callers 1

mainFunction · 0.70

Calls 1

to_stringFunction · 0.70

Tested by

no test coverage detected