test_platform.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@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 TestPlatform
  11. #include <boost/test/unit_test.hpp>
  12. #include <iostream>
  13. #include <boost/compute/platform.hpp>
  14. #include <boost/compute/system.hpp>
  15. BOOST_AUTO_TEST_CASE(platform_id)
  16. {
  17. boost::compute::platform platform =
  18. boost::compute::system::platforms().front();
  19. boost::compute::platform platform_copy(platform.id());
  20. BOOST_CHECK(platform == platform_copy);
  21. BOOST_CHECK(platform.id() == platform_copy.id());
  22. }
  23. BOOST_AUTO_TEST_CASE(platform_supports_extension)
  24. {
  25. boost::compute::platform platform =
  26. boost::compute::system::platforms().front();
  27. std::string extensions = platform.get_info<CL_PLATFORM_EXTENSIONS>();
  28. if(extensions.empty()){
  29. std::cerr << "platform doesn't support any extensions" << std::endl;
  30. return;
  31. }
  32. size_t space = extensions.find(' ');
  33. std::string first_extension = extensions.substr(0, space);
  34. BOOST_CHECK(platform.supports_extension(first_extension) == true);
  35. BOOST_CHECK(platform.supports_extension("invalid_extension_name") == false);
  36. }