From 4449422d38098b24682d7e22c4f9eb988066424b Mon Sep 17 00:00:00 2001
From: Xuan Thang Nguyen <nguyexu2@fit.cvut.cz>
Date: Wed, 24 Feb 2021 21:20:54 +0100
Subject: [PATCH] fix permutation

---
 bitonicGPU/unitTests/unitTests.cu | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/bitonicGPU/unitTests/unitTests.cu b/bitonicGPU/unitTests/unitTests.cu
index d1e9234..76b4bec 100644
--- a/bitonicGPU/unitTests/unitTests.cu
+++ b/bitonicGPU/unitTests/unitTests.cu
@@ -27,7 +27,7 @@ TEST(permutations, allPermutationSize_3_to_7)
         std::vector<int> orig(size);
         std::iota(orig.begin(), orig.end(), 0);
 
-        while (std::next_permutation(orig.begin(), orig.end()))
+        do
         {
             TNL::Containers::Array<int, TNL::Devices::Cuda> cudaArr(orig);
             auto view = cudaArr.getView();
@@ -36,6 +36,7 @@ TEST(permutations, allPermutationSize_3_to_7)
 
             ASSERT_TRUE(is_sorted(view)) << "failed " << i << std::endl;
         } 
+        while (std::next_permutation(orig.begin(), orig.end()));
     }
 }
 
@@ -48,7 +49,7 @@ TEST(permutations, somePermutationSize8)
     std::vector<int> orig(size);
     std::iota(orig.begin(), orig.end(), 0);
 
-    while (std::next_permutation(orig.begin(), orig.end()))
+    do
     {
         if ((i++) % stride != 0)
             continue;
@@ -60,6 +61,7 @@ TEST(permutations, somePermutationSize8)
 
         ASSERT_TRUE(is_sorted(view)) << "result " << view << std::endl;
     }
+    while (std::next_permutation(orig.begin(), orig.end()));
 }
 
 TEST(permutations, somePermutationSize9)
@@ -71,7 +73,7 @@ TEST(permutations, somePermutationSize9)
     std::vector<int> orig(size);
     std::iota(orig.begin(), orig.end(), 0);
 
-    while (std::next_permutation(orig.begin(), orig.end()))
+    do
     {
         if ((i++) % stride != 0)
             continue;
@@ -83,8 +85,11 @@ TEST(permutations, somePermutationSize9)
 
         ASSERT_TRUE(is_sorted(view)) << "result " << view << std::endl;
     }
+    while (std::next_permutation(orig.begin(), orig.end()));
 }
 
+//-----------------------------------------------------------------------
+
 TEST(selectedSize, size15)
 {
     TNL::Containers::Array<int, TNL::Devices::Cuda> cudaArr{5, 9, 4, 8, 6, 1, 2, 3, 4, 8, 1, 6, 9, 4, 9};
-- 
GitLab