blob: 8f7627a03c57fabe1652cfa916b6e616cba64425 [file] [log] [blame]
Ryan Harrisondbc13af2022-02-21 15:19:07 +00001// 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/tint/demangler.h"
16#include "src/tint/symbol_table.h"
17
18#include "gtest/gtest.h"
19
20namespace tint {
21namespace {
22
23using DemanglerTest = testing::Test;
24
25TEST_F(DemanglerTest, NoSymbols) {
dan sinclair41e4d9a2022-05-01 14:40:55 +000026 SymbolTable t{ProgramID::New()};
27 t.Register("sym1");
Ryan Harrisondbc13af2022-02-21 15:19:07 +000028
dan sinclair41e4d9a2022-05-01 14:40:55 +000029 Demangler d;
30 EXPECT_EQ("test str", d.Demangle(t, "test str"));
Ryan Harrisondbc13af2022-02-21 15:19:07 +000031}
32
33TEST_F(DemanglerTest, Symbol) {
dan sinclair41e4d9a2022-05-01 14:40:55 +000034 SymbolTable t{ProgramID::New()};
35 t.Register("sym1");
Ryan Harrisondbc13af2022-02-21 15:19:07 +000036
dan sinclair41e4d9a2022-05-01 14:40:55 +000037 Demangler d;
38 EXPECT_EQ("test sym1 str", d.Demangle(t, "test $1 str"));
Ryan Harrisondbc13af2022-02-21 15:19:07 +000039}
40
41TEST_F(DemanglerTest, MultipleSymbols) {
dan sinclair41e4d9a2022-05-01 14:40:55 +000042 SymbolTable t{ProgramID::New()};
43 t.Register("sym1");
44 t.Register("sym2");
Ryan Harrisondbc13af2022-02-21 15:19:07 +000045
dan sinclair41e4d9a2022-05-01 14:40:55 +000046 Demangler d;
47 EXPECT_EQ("test sym1 sym2 sym1 str", d.Demangle(t, "test $1 $2 $1 str"));
Ryan Harrisondbc13af2022-02-21 15:19:07 +000048}
49
50} // namespace
51} // namespace tint