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 15#include "test/unit_spirv.h" 16 17#include "test/test_fixture.h" 18 19namespace spvtools { 20namespace { 21 22using spvtest::ScopedContext; 23 24TEST(BinaryDestroy, Null) { 25 // There is no state or return value to check. Just check 26 // for the ability to call the API without abnormal termination. 27 spvBinaryDestroy(nullptr); 28} 29 30using BinaryDestroySomething = spvtest::TextToBinaryTest; 31 32// Checks safety of destroying a validly constructed binary. 33TEST_F(BinaryDestroySomething, Default) { 34 // Use a binary object constructed by the API instead of rolling our own. 35 SetText("OpSource OpenCL_C 120"); 36 spv_binary my_binary = nullptr; 37 ASSERT_EQ(SPV_SUCCESS, spvTextToBinary(ScopedContext().context, text.str, 38 text.length, &my_binary, &diagnostic)); 39 ASSERT_NE(nullptr, my_binary); 40 spvBinaryDestroy(my_binary); 41} 42 43} // namespace 44} // namespace spvtools 45