24 int test_data[] = {8, 1, 2, -4, 7, 9, 65536, 4, 9, 0};
30 std::locale::global(std::locale(
""));
46 EXPECT_FALSE(heap->
empty());
53 EXPECT_LT((*v)[0].key, v->
back().key);
54 for (
int i = 0; i < v->
size(); ++i) {
55 EXPECT_EQ((*v)[i].key, heap->
PeekTop().key);
57 if (i + 1 < v->
size() && (*v)[i + 1].key == (*v)[i].key) {
58 while (i + 1 < v->
size() && (*v)[i + 1].key == (*v)[i].key) {
61 EXPECT_FALSE(heap->
empty());
62 EXPECT_EQ((*v)[i].key, heap->
PeekTop().key);
66 EXPECT_EQ((*v)[i].data, heap->
PeekTop().data);
68 EXPECT_FALSE(heap->
empty());
69 EXPECT_TRUE(heap->
Pop(
nullptr));
71 EXPECT_TRUE(heap->
empty());
84 EXPECT_TRUE(heap.
empty());
86 EXPECT_EQ(heap.
size(), v.size());
88 PushTestData(&heap, &v);
89 VerifyHeapVectorMatch(&heap, &v);
99 PushTestData(&heap, &v);
102 for (
int i = 0; i < 5; ++i) {
107 PushTestData(&heap, &v);
109 VerifyHeapVectorMatch(&heap, &v);
118 PushTestData(&heap, &v);
122 EXPECT_EQ(pair.
key, 65536);
123 EXPECT_EQ(pair.
data, 6);
128 VerifyHeapVectorMatch(&heap, &v);
145 h_pair.data.Connect(&v_pair.data);
155 PtrPair* pair_ptr = PtrPair::RecastDataPointer(v[0].data.OtherEnd());
156 pair_ptr->key = v[0].key;
160 pair_ptr = PtrPair::RecastDataPointer(v[1].data.OtherEnd());
161 pair_ptr->key = v[1].key;
166 EXPECT_GT(v[0].key, v.
back().key);
167 for (
int i = 0; i < v.
size(); ++i) {
168 EXPECT_EQ(v[i].key, heap.
PeekTop().key);
169 EXPECT_FALSE(heap.
empty());
172 EXPECT_TRUE(heap.
empty());
179 static void ConstRefTest(
const DoublePtr& ptr1) {
180 DoublePtr ptr2(ptr1);
181 EXPECT_EQ(&ptr2, ptr2.OtherEnd()->OtherEnd());
182 EXPECT_TRUE(ptr1.OtherEnd() ==
nullptr);
194 EXPECT_TRUE(ptr1.
OtherEnd() ==
nullptr);
197 EXPECT_EQ(&ptr1, ptr1.OtherEnd()->OtherEnd());
198 EXPECT_TRUE(ptr3.
OtherEnd() ==
nullptr);