Skip to content

Commit b8600a4

Browse files
author
Raghuveer Devulapalli
committed
Update ky-value test to handle duplicate entires in key vector
1 parent 98fdfe3 commit b8600a4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

tests/test-keyvalue.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@ TYPED_TEST_P(simdkvsort, test_kvsort)
3535
for (auto type : this->arrtype) {
3636
bool hasnan = (type == "rand_with_nan") ? true : false;
3737
for (auto size : this->arrsize) {
38-
std::vector<T1> v1 = get_array<T1>(type, size);
39-
std::vector<T2> v2 = get_array<T2>(type, size);
40-
std::vector<T1> v1_bckp = v1;
41-
std::vector<T2> v2_bckp = v2;
42-
xss::scalar::keyvalue_qsort(v1_bckp.data(), v2_bckp.data(), size, hasnan);
43-
x86simdsort::keyvalue_qsort(v1.data(), v2.data(), size, hasnan);
44-
ASSERT_EQ(v1, v1_bckp);
45-
ASSERT_EQ(v2, v2_bckp);
46-
v1.clear(); v2.clear();
47-
v1_bckp.clear(); v2_bckp.clear();
38+
std::vector<T1> key = get_array<T1>(type, size);
39+
std::vector<T2> val = get_array<T2>(type, size);
40+
std::vector<T1> key_bckp = key;
41+
std::vector<T2> val_bckp = val;
42+
x86simdsort::keyvalue_qsort(key.data(), val.data(), size, hasnan);
43+
xss::scalar::keyvalue_qsort(key_bckp.data(), val_bckp.data(), size, hasnan);
44+
ASSERT_EQ(key, key_bckp);
45+
const bool hasDuplicates = std::adjacent_find(key.begin(), key.end()) != key.end();
46+
if (!hasDuplicates) {
47+
ASSERT_EQ(val, val_bckp);
48+
}
49+
key.clear(); val.clear();
50+
key_bckp.clear(); val_bckp.clear();
4851
}
4952
}
5053
}

0 commit comments

Comments
 (0)