1 // Copyright 2020 The Tint Authors.
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 "src/demangler.h"
16 #include "src/symbol_table.h"
17
18 #include "gtest/gtest.h"
19
20 namespace tint {
21 namespace {
22
23 using DemanglerTest = testing::Test;
24
TEST_F(DemanglerTest,NoSymbols)25 TEST_F(DemanglerTest, NoSymbols) {
26 SymbolTable t{ProgramID::New()};
27 t.Register("sym1");
28
29 Demangler d;
30 EXPECT_EQ("test str", d.Demangle(t, "test str"));
31 }
32
TEST_F(DemanglerTest,Symbol)33 TEST_F(DemanglerTest, Symbol) {
34 SymbolTable t{ProgramID::New()};
35 t.Register("sym1");
36
37 Demangler d;
38 EXPECT_EQ("test sym1 str", d.Demangle(t, "test $1 str"));
39 }
40
TEST_F(DemanglerTest,MultipleSymbols)41 TEST_F(DemanglerTest, MultipleSymbols) {
42 SymbolTable t{ProgramID::New()};
43 t.Register("sym1");
44 t.Register("sym2");
45
46 Demangler d;
47 EXPECT_EQ("test sym1 sym2 sym1 str", d.Demangle(t, "test $1 $2 $1 str"));
48 }
49
50 } // namespace
51 } // namespace tint
52