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
15TEST(RustDemangle, Success) {
16 char *Demangled = llvm::rustDemangle(MangledName: "_RNvC1a4main");
17 EXPECT_STREQ(Demangled, "a::main");
18 std::free(ptr: Demangled);
19}
20
21TEST(RustDemangle, Invalid) {
22 char *Demangled = nullptr;
23
24 // Invalid prefix.
25 Demangled = llvm::rustDemangle(MangledName: "_ABCDEF");
26 EXPECT_EQ(Demangled, nullptr);
27
28 // Correct prefix but still invalid.
29 Demangled = llvm::rustDemangle(MangledName: "_RRR");
30 EXPECT_EQ(Demangled, nullptr);
31}
32

source code of llvm/unittests/Demangle/RustDemangleTest.cpp