1 /*
2 * Copyright (C) 2023 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <string>
18
19 #include <gtest/gtest.h>
20
21 #include <unwindstack/Demangle.h>
22
23 namespace unwindstack {
24
TEST(DemangleTest,none)25 TEST(DemangleTest, none) {
26 EXPECT_EQ("", DemangleNameIfNeeded(""));
27 EXPECT_EQ("a", DemangleNameIfNeeded("a"));
28 EXPECT_EQ("_", DemangleNameIfNeeded("_"));
29 EXPECT_EQ("ab", DemangleNameIfNeeded("ab"));
30 EXPECT_EQ("abc", DemangleNameIfNeeded("abc"));
31 EXPECT_EQ("_R", DemangleNameIfNeeded("_R"));
32 EXPECT_EQ("_Z", DemangleNameIfNeeded("_Z"));
33 }
34
TEST(DemangleTest,cxx_names)35 TEST(DemangleTest, cxx_names) {
36 EXPECT_EQ("fake(bool)", DemangleNameIfNeeded("_Z4fakeb"));
37 EXPECT_EQ("demangle(int)", DemangleNameIfNeeded("_Z8demanglei"));
38 }
39
TEST(DemangleTest,rust_names)40 TEST(DemangleTest, rust_names) {
41 EXPECT_EQ("std::rt::lang_start_internal",
42 DemangleNameIfNeeded("_RNvNtCs2WRBrrl1bb1_3std2rt19lang_start_internal"));
43 EXPECT_EQ("profcollectd::main", DemangleNameIfNeeded("_RNvCs4VPobU5SDH_12profcollectd4main"));
44 }
45
46 } // namespace unwindstack
47