23int test_data[] = {8, 1, 2, -4, 7, 9, 65536, 4, 9, 0};
29 std::locale::global(std::locale(
""));
45 EXPECT_FALSE(heap->
empty());
46 EXPECT_EQ(heap->
size(), v->size());
50 std::sort(v->begin(), v->end());
52 EXPECT_LT((*v)[0].key(), v->back().key());
53 for (
unsigned i = 0; i < v->size(); ++i) {
54 EXPECT_EQ((*v)[i].key(), heap->
PeekTop().key());
56 if (i + 1 < v->size() && (*v)[i + 1].key() == (*v)[i].key()) {
57 while (i + 1 < v->size() && (*v)[i + 1].key() == (*v)[i].key()) {
60 EXPECT_FALSE(heap->
empty());
61 EXPECT_EQ((*v)[i].key(), heap->
PeekTop().key());
65 EXPECT_EQ((*v)[i].data(), heap->
PeekTop().data());
67 EXPECT_FALSE(heap->
empty());
68 EXPECT_TRUE(heap->
Pop(
nullptr));
70 EXPECT_TRUE(heap->
empty());
83 EXPECT_TRUE(heap.
empty());
85 EXPECT_EQ(heap.
size(), v.size());
87 PushTestData(&heap, &v);
88 VerifyHeapVectorMatch(&heap, &v);
98 PushTestData(&heap, &v);
100 std::sort(v.begin(), v.end());
101 for (
int i = 0; i < 5; ++i) {
106 PushTestData(&heap, &v);
108 VerifyHeapVectorMatch(&heap, &v);
117 PushTestData(&heap, &v);
121 EXPECT_EQ(pair.
key(), 65536);
122 EXPECT_EQ(pair.
data(), 6);
124 std::sort(v.begin(), v.end());
125 v.resize(v.size() - 1);
127 VerifyHeapVectorMatch(&heap, &v);
137 std::vector<PtrPair> v;
144 h_pair.data().Connect(&v_pair.data());
154 auto *pair_ptr =
reinterpret_cast<PtrPair *
>(v[0].data().OtherEnd());
155 pair_ptr->key() = v[0].key();
159 pair_ptr =
reinterpret_cast<PtrPair *
>(v[1].data().OtherEnd());
160 pair_ptr->key() = v[1].key();
164 std::sort(v.begin(), v.end());
165 EXPECT_GT(v[0].key(), v.back().key());
167 EXPECT_EQ(i.key(), heap.
PeekTop().key());
168 EXPECT_FALSE(heap.
empty());
171 EXPECT_TRUE(heap.
empty());
178static void ConstRefTest(
const DoublePtr& ptr1) {
179 DoublePtr ptr2(ptr1);
180 EXPECT_EQ(&ptr2, ptr2.OtherEnd()->OtherEnd());
181 EXPECT_TRUE(ptr1.OtherEnd() ==
nullptr);
193 EXPECT_TRUE(ptr1.
OtherEnd() ==
nullptr);
197 EXPECT_TRUE(ptr3.
OtherEnd() ==
nullptr);
constexpr size_t countof(T const (&)[N]) noexcept
TEST_F(EuroText, FastLatinOCR)
bool PopWorst(Pair *entry)
const Pair & PeekTop() const
void Reshuffle(Pair *pair)
DoublePtr * OtherEnd() const
void Connect(DoublePtr *other)
void VerifyHeapVectorMatch(GenericHeap< IntKDPair > *heap, KDVector *v)
void PushTestData(GenericHeap< IntKDPair > *heap, KDVector *v)