xref: /llvm-project/llvm/unittests/Demangle/RustDemangleTest.cpp (revision 201c4b9cc4a649e4a54b418749ab5b8bd227e4f0)
1 //===------------------ RustDemangleTest.cpp ------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/Demangle/Demangle.h"
10 #include "gmock/gmock.h"
11 #include "gtest/gtest.h"
12 
13 #include <cstdlib>
14 
TEST(RustDemangle,Success)15 TEST(RustDemangle, Success) {
16   char *Demangled = llvm::rustDemangle("_RNvC1a4main");
17   EXPECT_STREQ(Demangled, "a::main");
18   std::free(Demangled);
19 }
20 
TEST(RustDemangle,Invalid)21 TEST(RustDemangle, Invalid) {
22   char *Demangled = nullptr;
23 
24   // Invalid prefix.
25   Demangled = llvm::rustDemangle("_ABCDEF");
26   EXPECT_EQ(Demangled, nullptr);
27 
28   // Correct prefix but still invalid.
29   Demangled = llvm::rustDemangle("_RRR");
30   EXPECT_EQ(Demangled, nullptr);
31 }
32