binary_destroy_test.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2015-2016 The Khronos Group Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "test/unit_spirv.h"
  15. #include "test/test_fixture.h"
  16. namespace spvtools {
  17. namespace {
  18. using spvtest::ScopedContext;
  19. TEST(BinaryDestroy, Null) {
  20. // There is no state or return value to check. Just check
  21. // for the ability to call the API without abnormal termination.
  22. spvBinaryDestroy(nullptr);
  23. }
  24. using BinaryDestroySomething = spvtest::TextToBinaryTest;
  25. // Checks safety of destroying a validly constructed binary.
  26. TEST_F(BinaryDestroySomething, Default) {
  27. // Use a binary object constructed by the API instead of rolling our own.
  28. SetText("OpSource OpenCL_C 120");
  29. spv_binary my_binary = nullptr;
  30. ASSERT_EQ(SPV_SUCCESS, spvTextToBinary(ScopedContext().context, text.str,
  31. text.length, &my_binary, &diagnostic));
  32. ASSERT_NE(nullptr, my_binary);
  33. spvBinaryDestroy(my_binary);
  34. }
  35. } // namespace
  36. } // namespace spvtools