Skip to content

Commit fb09010

Browse files
author
Raghuveer Devulapalli
committed
Update tests to pass the right hasnan value
1 parent bae0eff commit fb09010

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/test-qsort.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ TYPED_TEST_SUITE_P(simdsort);
2929
TYPED_TEST_P(simdsort, test_qsort)
3030
{
3131
for (auto type : this->arrtype) {
32+
bool hasnan = (type == "rand_with_nan") ? true : false;
3233
for (auto size : this->arrsize) {
3334
std::vector<TypeParam> arr = get_array<TypeParam>(type, size);
3435
std::vector<TypeParam> sortedarr = arr;
3536
std::sort(sortedarr.begin(),
3637
sortedarr.end(),
3738
compare<TypeParam, std::less<TypeParam>>());
38-
x86simdsort::qsort(arr.data(), arr.size());
39+
x86simdsort::qsort(arr.data(), arr.size(), hasnan);
3940
IS_SORTED(sortedarr, arr, type);
4041
arr.clear();
4142
sortedarr.clear();
@@ -46,13 +47,14 @@ TYPED_TEST_P(simdsort, test_qsort)
4647
TYPED_TEST_P(simdsort, test_argsort)
4748
{
4849
for (auto type : this->arrtype) {
50+
bool hasnan = (type == "rand_with_nan") ? true : false;
4951
for (auto size : this->arrsize) {
5052
std::vector<TypeParam> arr = get_array<TypeParam>(type, size);
5153
std::vector<TypeParam> sortedarr = arr;
5254
std::sort(sortedarr.begin(),
5355
sortedarr.end(),
5456
compare<TypeParam, std::less<TypeParam>>());
55-
auto arg = x86simdsort::argsort(arr.data(), arr.size());
57+
auto arg = x86simdsort::argsort(arr.data(), arr.size(), hasnan);
5658
IS_ARG_SORTED(sortedarr, arr, arg, type);
5759
arr.clear();
5860
arg.clear();
@@ -63,6 +65,7 @@ TYPED_TEST_P(simdsort, test_argsort)
6365
TYPED_TEST_P(simdsort, test_qselect)
6466
{
6567
for (auto type : this->arrtype) {
68+
bool hasnan = (type == "rand_with_nan") ? true : false;
6669
for (auto size : this->arrsize) {
6770
size_t k = rand() % size;
6871
std::vector<TypeParam> arr = get_array<TypeParam>(type, size);
@@ -71,7 +74,7 @@ TYPED_TEST_P(simdsort, test_qselect)
7174
sortedarr.begin() + k,
7275
sortedarr.end(),
7376
compare<TypeParam, std::less<TypeParam>>());
74-
x86simdsort::qselect(arr.data(), k, arr.size(), true);
77+
x86simdsort::qselect(arr.data(), k, arr.size(), hasnan);
7578
IS_ARR_PARTITIONED(arr, k, sortedarr[k], type);
7679
arr.clear();
7780
sortedarr.clear();
@@ -82,15 +85,15 @@ TYPED_TEST_P(simdsort, test_qselect)
8285
TYPED_TEST_P(simdsort, test_argselect)
8386
{
8487
for (auto type : this->arrtype) {
88+
bool hasnan = (type == "rand_with_nan") ? true : false;
8589
for (auto size : this->arrsize) {
8690
size_t k = rand() % size;
8791
std::vector<TypeParam> arr = get_array<TypeParam>(type, size);
8892
std::vector<TypeParam> sortedarr = arr;
8993
std::sort(sortedarr.begin(),
9094
sortedarr.end(),
9195
compare<TypeParam, std::less<TypeParam>>());
92-
auto arg = x86simdsort::argselect(arr.data(), k, arr.size());
93-
auto arg1 = x86simdsort::argsort(arr.data(), arr.size());
96+
auto arg = x86simdsort::argselect(arr.data(), k, arr.size(), hasnan);
9497
IS_ARG_PARTITIONED(arr, arg, sortedarr[k], k, type);
9598
arr.clear();
9699
sortedarr.clear();
@@ -101,6 +104,7 @@ TYPED_TEST_P(simdsort, test_argselect)
101104
TYPED_TEST_P(simdsort, test_partial_qsort)
102105
{
103106
for (auto type : this->arrtype) {
107+
bool hasnan = (type == "rand_with_nan") ? true : false;
104108
for (auto size : this->arrsize) {
105109
// k should be at least 1
106110
size_t k = std::max((size_t)1, rand() % size);
@@ -109,7 +113,7 @@ TYPED_TEST_P(simdsort, test_partial_qsort)
109113
std::sort(sortedarr.begin(),
110114
sortedarr.end(),
111115
compare<TypeParam, std::less<TypeParam>>());
112-
x86simdsort::partial_qsort(arr.data(), k, arr.size(), true);
116+
x86simdsort::partial_qsort(arr.data(), k, arr.size(), hasnan);
113117
IS_ARR_PARTIALSORTED(arr, k, sortedarr, type);
114118
arr.clear();
115119
sortedarr.clear();

0 commit comments

Comments
 (0)