gapi_infer_tests.cpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. //
  5. // Copyright (C) 2020 Intel Corporation
  6. #include "../test_precomp.hpp"
  7. // These tests verify some parts of cv::gapi::infer<> API
  8. // regardless of the backend used
  9. namespace opencv_test {
  10. namespace {
  11. template<class A, class B> using Check = cv::detail::valid_infer2_types<A, B>;
  12. TEST(Infer, ValidInfer2Types)
  13. {
  14. // Compiled == passed!
  15. // Argument block 1
  16. static_assert(Check< std::tuple<cv::GMat> // Net
  17. , std::tuple<cv::GMat> > // Call
  18. ::value == true, "Must work");
  19. static_assert(Check< std::tuple<cv::GMat, cv::GMat> // Net
  20. , std::tuple<cv::GMat, cv::GMat> > // Call
  21. ::value == true, "Must work");
  22. // Argument block 2
  23. static_assert(Check< std::tuple<cv::GMat> // Net
  24. , std::tuple<cv::Rect> > // Call
  25. ::value == true, "Must work");
  26. static_assert(Check< std::tuple<cv::GMat, cv::GMat> // Net
  27. , std::tuple<cv::Rect, cv::Rect> > // Call
  28. ::value == true, "Must work");
  29. // Argument block 3 (mixed cases)
  30. static_assert(Check< std::tuple<cv::GMat, cv::GMat> // Net
  31. , std::tuple<cv::GMat, cv::Rect> > // Call
  32. ::value == true, "Must work");
  33. static_assert(Check< std::tuple<cv::GMat, cv::GMat> // Net
  34. , std::tuple<cv::Rect, cv::GMat> > // Call
  35. ::value == true, "Must work");
  36. // Argument block 4 (super-mixed)
  37. static_assert(Check< std::tuple<cv::GMat, cv::GMat, cv::GMat> // Net
  38. , std::tuple<cv::Rect, cv::GMat, cv::Rect> > // Call
  39. ::value == true, "Must work");
  40. // Argument block 5 (mainly negative)
  41. static_assert(Check< std::tuple<cv::GMat> // Net
  42. , std::tuple<int> > // Call
  43. ::value == false, "This type(s) shouldn't pass");
  44. static_assert(Check< std::tuple<cv::GMat, cv::GMat> // Net
  45. , std::tuple<int, cv::Rect> > // Call
  46. ::value == false, "This type(s) shouldn't pass");
  47. static_assert(Check< std::tuple<cv::GMat, cv::GMat> // Net
  48. , std::tuple<cv::Rect, cv::Point> >// Call
  49. ::value == false, "This type(s) shouldn't pass");
  50. // Argument block 5 (wrong args length)
  51. static_assert(Check< std::tuple<cv::GMat, cv::GMat> // Net
  52. , std::tuple<cv::GMat> > // Call
  53. ::value == false, "Should fail -- not enough args");
  54. static_assert(Check< std::tuple<cv::GMat, cv::GMat> // Net
  55. , std::tuple<cv::Rect> > // Call
  56. ::value == false, "Should fail -- not enough args");
  57. static_assert(Check< std::tuple<cv::GMat, cv::GMat> // Net
  58. , std::tuple<cv::Rect, cv::Rect, cv::GMat> > // Call
  59. ::value == false, "Should fail -- too much args");
  60. }
  61. } // anonymous namespace
  62. } // namespace opencv_test