mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-04 22:07:27 +00:00
651aa689cc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79359 91177308-0d34-0410-b5e6-96231b3b80d8
150 lines
4.3 KiB
C++
150 lines
4.3 KiB
C++
//===----------- Triple.cpp - Triple unit tests ---------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "gtest/gtest.h"
|
|
#include "llvm/ADT/Triple.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
|
|
TEST(TripleTest, BasicParsing) {
|
|
Triple T;
|
|
|
|
T = Triple("");
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
|
|
|
T = Triple("-");
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
|
|
|
T = Triple("--");
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
|
|
|
T = Triple("---");
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
|
|
|
T = Triple("----");
|
|
EXPECT_EQ("", T.getArchName().str());
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
EXPECT_EQ("-", T.getEnvironmentName().str());
|
|
|
|
T = Triple("a");
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
EXPECT_EQ("", T.getVendorName().str());
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
|
|
|
T = Triple("a-b");
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
EXPECT_EQ("b", T.getVendorName().str());
|
|
EXPECT_EQ("", T.getOSName().str());
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
|
|
|
T = Triple("a-b-c");
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
EXPECT_EQ("b", T.getVendorName().str());
|
|
EXPECT_EQ("c", T.getOSName().str());
|
|
EXPECT_EQ("", T.getEnvironmentName().str());
|
|
|
|
T = Triple("a-b-c-d");
|
|
EXPECT_EQ("a", T.getArchName().str());
|
|
EXPECT_EQ("b", T.getVendorName().str());
|
|
EXPECT_EQ("c", T.getOSName().str());
|
|
EXPECT_EQ("d", T.getEnvironmentName().str());
|
|
}
|
|
|
|
TEST(TripleTest, ParsedIDs) {
|
|
Triple T;
|
|
|
|
T = Triple("i386-apple-darwin");
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
EXPECT_EQ(Triple::Apple, T.getVendor());
|
|
EXPECT_EQ(Triple::Darwin, T.getOS());
|
|
|
|
T = Triple("x86_64-pc-linux-gnu");
|
|
EXPECT_EQ(Triple::x86_64, T.getArch());
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
|
|
T = Triple("powerpc-dunno-notsure");
|
|
EXPECT_EQ(Triple::ppc, T.getArch());
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
T = Triple("huh");
|
|
EXPECT_EQ(Triple::UnknownArch, T.getArch());
|
|
|
|
// Two exceptional cases.
|
|
|
|
T = Triple("i386-mingw32");
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
EXPECT_EQ(Triple::MinGW32, T.getOS());
|
|
|
|
T = Triple("arm-elf");
|
|
EXPECT_EQ(Triple::arm, T.getArch());
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
}
|
|
|
|
TEST(TripleTest, MutateName) {
|
|
Triple T;
|
|
EXPECT_EQ(Triple::UnknownArch, T.getArch());
|
|
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
|
|
EXPECT_EQ(Triple::UnknownOS, T.getOS());
|
|
|
|
T.setArchName("i386");
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
EXPECT_EQ("i386--", T.getTriple());
|
|
|
|
T.setVendorName("pc");
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
EXPECT_EQ("i386-pc-", T.getTriple());
|
|
|
|
T.setOSName("linux");
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
EXPECT_EQ("i386-pc-linux", T.getTriple());
|
|
|
|
T.setEnvironmentName("gnu");
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
EXPECT_EQ(Triple::Linux, T.getOS());
|
|
EXPECT_EQ("i386-pc-linux-gnu", T.getTriple());
|
|
|
|
T.setOSName("freebsd");
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
EXPECT_EQ(Triple::FreeBSD, T.getOS());
|
|
EXPECT_EQ("i386-pc-freebsd-gnu", T.getTriple());
|
|
|
|
T.setOSAndEnvironmentName("darwin");
|
|
EXPECT_EQ(Triple::x86, T.getArch());
|
|
EXPECT_EQ(Triple::PC, T.getVendor());
|
|
EXPECT_EQ(Triple::Darwin, T.getOS());
|
|
EXPECT_EQ("i386-pc-darwin", T.getTriple());
|
|
}
|
|
|
|
}
|