TestRaddix.cxx File Reference
#include <gtest/gtest.h>
#include <raddix.hxx>
Include dependency graph for TestRaddix.cxx:

Go to the source code of this file.

Functions

 TEST (TestRaddix, RaddixSorts)
 

Function Documentation

TEST ( TestRaddix  ,
RaddixSorts   
)

Definition at line 39 of file TestRaddix.cxx.

40 {
41  // Normal Run - array should be sorted in order
42  {
43  Container randomdArrayPos(RandomArrayIntPos, RandomArrayIntPos + sizeof(RandomArrayIntPos) / sizeof(int));
44  RaddixSort<IT>(randomdArrayPos.begin(), randomdArrayPos.end());
45 
46  // All elements are sorted
47  for (IT it = randomdArrayPos.begin(); it < randomdArrayPos.end() - 1; ++it)
48  EXPECT_LE(*it, *(it + 1));
49  }
50 
51  // Already sortedArray - Array should not be affected
52  {
53  Container sortedArrayPos(SortedArrayIntPos, SortedArrayIntPos + sizeof(SortedArrayIntPos) / sizeof(int));
54  RaddixSort<IT>(sortedArrayPos.begin(), sortedArrayPos.end());
55 
56  // All elements are still sorted
57  for (IT it = sortedArrayPos.begin(); it < sortedArrayPos.end() - 1; ++it)
58  EXPECT_LE(*it, *(it + 1));
59  }
60 
61  // Inverse iterator order - Array should not be affected
62  {
63  Container randomArrayPos(RandomArrayIntPos, RandomArrayIntPos + sizeof(RandomArrayIntPos) / sizeof(int));
64  RaddixSort<IT>(randomArrayPos.end(), randomArrayPos.begin());
65 
66  int i = 0;
67  for (IT it = randomArrayPos.begin(); it < randomArrayPos.end(); ++it, ++i)
68  EXPECT_EQ(RandomArrayIntPos[i], *it);
69  }
70 
71  // No error empty array
72  {
73  Container emptyArray;
74  RaddixSort<IT>(emptyArray.begin(), emptyArray.end());
75  }
76 
77  // Unique value array - Array should not be affected
78  {
79  Container uniqueValueArray(1, 511);
80  RaddixSort<IT>(uniqueValueArray.begin(), uniqueValueArray.end());
81  EXPECT_EQ(511, uniqueValueArray[0]);
82  }
83 }