Skip to content

Commit 9c3be68

Browse files
committed
add tests
1 parent 3269c8c commit 9c3be68

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/test.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,26 @@ BOOST_AUTO_TEST_CASE( shuffle1024 ) {
136136
}
137137
}
138138

139+
BOOST_AUTO_TEST_CASE( shuffle1024r ) {
140+
const int size = 1024;
141+
142+
std::vector<int> a;
143+
for(int i = 0; i < size; ++i) {
144+
a.push_back((i+1) * 10);
145+
}
146+
147+
for(int n = 0; n < 100; ++n) {
148+
std::random_shuffle(a.begin(), a.end());
149+
150+
timsort(a.begin(), a.end(), std::greater<int>());
151+
152+
int j = size;
153+
for(int i = 0; i < size; ++i) {
154+
BOOST_CHECK_EQUAL( a[i], (--j+1) * 10 );
155+
}
156+
}
157+
}
158+
139159
BOOST_AUTO_TEST_CASE( c_array ) {
140160
int a[] = { 7, 1, 5, 3, 9 };
141161

@@ -148,6 +168,18 @@ BOOST_AUTO_TEST_CASE( c_array ) {
148168
BOOST_CHECK_EQUAL(a[4], 9);
149169
}
150170

171+
BOOST_AUTO_TEST_CASE( string_array ) {
172+
std::string a[] = { "7", "1", "5", "3", "9" };
173+
174+
timsort(a, a + sizeof(a) / sizeof(std::string), std::less<std::string>());
175+
176+
BOOST_CHECK_EQUAL(a[0], "1");
177+
BOOST_CHECK_EQUAL(a[1], "3");
178+
BOOST_CHECK_EQUAL(a[2], "5");
179+
BOOST_CHECK_EQUAL(a[3], "7");
180+
BOOST_CHECK_EQUAL(a[4], "9");
181+
}
182+
151183
struct NonDefaultConstructible
152184
{
153185
int i;

0 commit comments

Comments
 (0)