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