1 // Copyright (c) 2015-2016 The Khronos Group Inc.
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 #include "unit_spirv.h"
19 TEST(TextDestroy, DestroyNull) { spvBinaryDestroy(nullptr); }
21 TEST(TextDestroy, Default) {
22 spv_context context = spvContextCreate(SPV_ENV_UNIVERSAL_1_0);
25 OpMemoryModel Physical64 OpenCL
26 OpSourceExtension "PlaceholderExtensionName"
27 OpEntryPoint Kernel %0 ""
28 OpExecutionMode %0 LocalSizeHint 1 1 1
42 %14 = OpTypeVector %3 2
45 spv_binary binary = nullptr;
46 spv_diagnostic diagnostic = nullptr;
47 EXPECT_EQ(SPV_SUCCESS, spvTextToBinary(context, textStr, strlen(textStr),
48 &binary, &diagnostic));
49 EXPECT_NE(nullptr, binary);
50 EXPECT_NE(nullptr, binary->code);
51 EXPECT_NE(0u, binary->wordCount);
53 spvDiagnosticPrint(diagnostic);
57 spv_text resultText = nullptr;
58 EXPECT_EQ(SPV_SUCCESS,
59 spvBinaryToText(context, binary->code, binary->wordCount, 0,
60 &resultText, &diagnostic));
61 spvBinaryDestroy(binary);
63 spvDiagnosticPrint(diagnostic);
64 spvDiagnosticDestroy(diagnostic);
67 EXPECT_NE(nullptr, resultText->str);
68 EXPECT_NE(0u, resultText->length);
69 spvTextDestroy(resultText);
70 spvContextDestroy(context);
73 } // anonymous namespace