2020-12-11 18:29:03 +00:00
|
|
|
// Copyright 2020 The Tint Authors.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "src/demangler.h"
|
2021-01-26 16:57:10 +00:00
|
|
|
#include "src/symbol_table.h"
|
2020-12-11 18:29:03 +00:00
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
namespace tint {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
using DemanglerTest = testing::Test;
|
|
|
|
|
|
|
|
TEST_F(DemanglerTest, NoSymbols) {
|
2021-04-15 18:20:03 +00:00
|
|
|
SymbolTable t{ProgramID::New()};
|
2021-01-26 16:57:10 +00:00
|
|
|
t.Register("sym1");
|
2020-12-11 18:29:03 +00:00
|
|
|
|
|
|
|
Demangler d;
|
2021-01-26 16:57:10 +00:00
|
|
|
EXPECT_EQ("test str", d.Demangle(t, "test str"));
|
2020-12-11 18:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DemanglerTest, Symbol) {
|
2021-04-15 18:20:03 +00:00
|
|
|
SymbolTable t{ProgramID::New()};
|
2021-01-26 16:57:10 +00:00
|
|
|
t.Register("sym1");
|
2020-12-11 18:29:03 +00:00
|
|
|
|
|
|
|
Demangler d;
|
2021-04-13 20:07:57 +00:00
|
|
|
EXPECT_EQ("test sym1 str", d.Demangle(t, "test $1 str"));
|
2020-12-11 18:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DemanglerTest, MultipleSymbols) {
|
2021-04-15 18:20:03 +00:00
|
|
|
SymbolTable t{ProgramID::New()};
|
2021-01-26 16:57:10 +00:00
|
|
|
t.Register("sym1");
|
|
|
|
t.Register("sym2");
|
2020-12-11 18:29:03 +00:00
|
|
|
|
|
|
|
Demangler d;
|
2021-04-13 20:07:57 +00:00
|
|
|
EXPECT_EQ("test sym1 sym2 sym1 str", d.Demangle(t, "test $1 $2 $1 str"));
|
2020-12-11 18:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace tint
|