test_stable_partition.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2014 Roshan <thisisroshansmail@gmail.com>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #define BOOST_TEST_MODULE TestStablePartition
  11. #include <boost/test/unit_test.hpp>
  12. #include <boost/compute/system.hpp>
  13. #include <boost/compute/functional.hpp>
  14. #include <boost/compute/command_queue.hpp>
  15. #include <boost/compute/algorithm/stable_partition.hpp>
  16. #include <boost/compute/container/vector.hpp>
  17. #include "check_macros.hpp"
  18. #include "context_setup.hpp"
  19. namespace bc = boost::compute;
  20. BOOST_AUTO_TEST_CASE(partition_int)
  21. {
  22. int dataset[] = {1, 1, -2, 0, 5, -1, 2, 4, 0, -1};
  23. bc::vector<bc::int_> vector(dataset, dataset + 10, queue);
  24. bc::vector<bc::int_>::iterator iter =
  25. bc::stable_partition(vector.begin(), vector.begin() + 10,
  26. bc::_1 > 0, queue);
  27. CHECK_RANGE_EQUAL(int, 10, vector, (1, 1, 5, 2, 4, -2, 0, -1, 0, -1));
  28. BOOST_VERIFY(iter == vector.begin()+5);
  29. }
  30. BOOST_AUTO_TEST_SUITE_END()