//---------------------------------------------------------------------------// // Copyright (c) 2013 Kyle Lutz // // Distributed under the Boost Software License, Version 1.0 // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // // See http://kylelutz.github.com/compute for more information. //---------------------------------------------------------------------------// #define BOOST_TEST_MODULE TestStableSort #include #include #include #include #include #include "check_macros.hpp" #include "context_setup.hpp" BOOST_AUTO_TEST_CASE(sort_int_vector) { int data[] = { -4, 152, -5000, 963, 75321, -456, 0, 1112 }; boost::compute::vector vector(data, data + 8); BOOST_CHECK_EQUAL(vector.size(), size_t(8)); BOOST_CHECK(boost::compute::is_sorted(vector.begin(), vector.end()) == false); boost::compute::stable_sort(vector.begin(), vector.end()); BOOST_CHECK(boost::compute::is_sorted(vector.begin(), vector.end()) == true); CHECK_RANGE_EQUAL(int, 8, vector, (-5000, -456, -4, 0, 152, 963, 1112, 75321)); } BOOST_AUTO_TEST_SUITE_END()