Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 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/tint/demangler.h" |
| 16 | #include "src/tint/symbol_table.h" |
| 17 | |
| 18 | #include "gtest/gtest.h" |
| 19 | |
| 20 | namespace tint { |
| 21 | namespace { |
| 22 | |
| 23 | using DemanglerTest = testing::Test; |
| 24 | |
| 25 | TEST_F(DemanglerTest, NoSymbols) { |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 26 | SymbolTable t{ProgramID::New()}; |
| 27 | t.Register("sym1"); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 28 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 29 | Demangler d; |
| 30 | EXPECT_EQ("test str", d.Demangle(t, "test str")); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | TEST_F(DemanglerTest, Symbol) { |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 34 | SymbolTable t{ProgramID::New()}; |
| 35 | t.Register("sym1"); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 36 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 37 | Demangler d; |
| 38 | EXPECT_EQ("test sym1 str", d.Demangle(t, "test $1 str")); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | TEST_F(DemanglerTest, MultipleSymbols) { |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 42 | SymbolTable t{ProgramID::New()}; |
| 43 | t.Register("sym1"); |
| 44 | t.Register("sym2"); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 45 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 46 | Demangler d; |
| 47 | EXPECT_EQ("test sym1 sym2 sym1 str", d.Demangle(t, "test $1 $2 $1 str")); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | } // namespace |
| 51 | } // namespace tint |