brintos

brintos / llvm-project-archived public Read only

0
0
Text · 904 B · e48ddb7 Raw
32 lines · cpp
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-exception6//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("_RNvC1a4main");17  EXPECT_STREQ(Demangled, "a::main");18  std::free(Demangled);19}20 21TEST(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