1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[llvm][TextAPI] rename test vars, NFC

* Conforms to clang tidy
This commit is contained in:
Cyndy Ishida 2020-02-14 14:05:59 -08:00
parent 8b8bfe27e8
commit f6b2bf396a
3 changed files with 378 additions and 406 deletions

View File

@ -41,7 +41,7 @@ static ExportedSymbol TBDv1Symbols[] = {
namespace TBDv1 {
TEST(TBDv1, ReadFile) {
static const char tbd_v1_file1[] =
static const char TBDv1File1[] =
"---\n"
"archs: [ armv7, armv7s, armv7k, arm64 ]\n"
"platform: ios\n"
@ -66,7 +66,7 @@ TEST(TBDv1, ReadFile) {
" thread-local-symbols: [ _tlv3 ]\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_file1, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1File1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
@ -113,13 +113,13 @@ TEST(TBDv1, ReadFile) {
}
TEST(TBDv1, ReadFile2) {
static const char tbd_v1_file2[] = "--- !tapi-tbd-v1\n"
"archs: [ armv7, armv7s, armv7k, arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv1File2[] = "--- !tapi-tbd-v1\n"
"archs: [ armv7, armv7s, armv7k, arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_file2, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1File2, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
@ -144,7 +144,7 @@ TEST(TBDv1, ReadFile2) {
}
TEST(TBDv1, WriteFile) {
static const char tbd_v1_file3[] =
static const char TBDv1File3[] =
"---\n"
"archs: [ i386, x86_64 ]\n"
"platform: macosx\n"
@ -193,18 +193,18 @@ TEST(TBDv1, WriteFile) {
raw_svector_ostream OS(Buffer);
auto Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(tbd_v1_file3, Buffer.c_str());
EXPECT_STREQ(TBDv1File3, Buffer.c_str());
}
TEST(TBDv1, Platform_macOS) {
static const char tbd_v1_platform_macos[] = "---\n"
"archs: [ x86_64 ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv1PlatformMacOS[] = "---\n"
"archs: [ x86_64 ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_macos, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv1PlatformMacOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::macOS;
auto File = std::move(Result.get());
@ -214,14 +214,14 @@ TEST(TBDv1, Platform_macOS) {
}
TEST(TBDv1, Platform_iOS) {
static const char tbd_v1_platform_ios[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv1PlatformiOS[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_ios, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv1PlatformiOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::iOS;
auto File = std::move(Result.get());
@ -231,14 +231,14 @@ TEST(TBDv1, Platform_iOS) {
}
TEST(TBDv1, Platform_watchOS) {
static const char tbd_v1_platform_watchos[] = "---\n"
"archs: [ armv7k ]\n"
"platform: watchos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv1PlatformWatchOS[] = "---\n"
"archs: [ armv7k ]\n"
"platform: watchos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_watchos, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv1PlatformWatchOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::watchOS;
auto File = std::move(Result.get());
@ -248,14 +248,14 @@ TEST(TBDv1, Platform_watchOS) {
}
TEST(TBDv1, Platform_tvOS) {
static const char tbd_v1_platform_tvos[] = "---\n"
"archs: [ arm64 ]\n"
"platform: tvos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv1PlatformtvOS[] = "---\n"
"archs: [ arm64 ]\n"
"platform: tvos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_tvos, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv1PlatformtvOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::tvOS;
auto File = std::move(Result.get());
@ -265,14 +265,13 @@ TEST(TBDv1, Platform_tvOS) {
}
TEST(TBDv1, Platform_bridgeOS) {
static const char tbd_v1_platform_bridgeos[] = "---\n"
"archs: [ armv7k ]\n"
"platform: bridgeos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv1BridgeOS[] = "---\n"
"archs: [ armv7k ]\n"
"platform: bridgeos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_platform_bridgeos, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1BridgeOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::bridgeOS;
auto File = std::move(Result.get());
@ -282,15 +281,14 @@ TEST(TBDv1, Platform_bridgeOS) {
}
TEST(TBDv1, Swift_1_0) {
static const char tbd_v1_swift_1_0[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 1.0\n"
"...\n";
static const char TBDv1Swift1[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 1.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
@ -298,15 +296,14 @@ TEST(TBDv1, Swift_1_0) {
}
TEST(TBDv1, Swift_1_1) {
static const char tbd_v1_swift_1_1[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 1.1\n"
"...\n";
static const char TBDv1Swift1dot[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 1.1\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_1_1, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift1dot, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
@ -314,15 +311,14 @@ TEST(TBDv1, Swift_1_1) {
}
TEST(TBDv1, Swift_2_0) {
static const char tbd_v1_swift_2_0[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 2.0\n"
"...\n";
static const char TBDv1Swift2[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 2.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_2_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift2, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
@ -330,15 +326,14 @@ TEST(TBDv1, Swift_2_0) {
}
TEST(TBDv1, Swift_3_0) {
static const char tbd_v1_swift_3_0[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 3.0\n"
"...\n";
static const char TBDv1Swift3[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 3.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_3_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift3, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
@ -346,15 +341,14 @@ TEST(TBDv1, Swift_3_0) {
}
TEST(TBDv1, Swift_4_0) {
static const char tbd_v1_swift_4_0[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 4.0\n"
"...\n";
static const char TBDv1Swift4[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 4.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_4_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift4, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:5:16: error: invalid Swift ABI "
@ -363,14 +357,14 @@ TEST(TBDv1, Swift_4_0) {
}
TEST(TBDv1, Swift_5) {
static const char tbd_v1_swift_5[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 5\n"
"...\n";
static const char TBDv1Swift5[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 5\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_5, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift5, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
@ -378,15 +372,14 @@ TEST(TBDv1, Swift_5) {
}
TEST(TBDv1, Swift_99) {
static const char tbd_v1_swift_99[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 99\n"
"...\n";
static const char TBDv1Swift99[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 99\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v1_swift_99, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift99, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
@ -394,26 +387,25 @@ TEST(TBDv1, Swift_99) {
}
TEST(TBDv1, UnknownArchitecture) {
static const char tbd_v1_file_unknown_architecture[] =
"---\n"
"archs: [ foo ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv1FileUnknownArch[] = "---\n"
"archs: [ foo ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(
MemoryBufferRef(tbd_v1_file_unknown_architecture, "Test.tbd"));
auto Result =
TextAPIReader::get(MemoryBufferRef(TBDv1FileUnknownArch, "Test.tbd"));
EXPECT_TRUE(!!Result);
}
TEST(TBDv1, UnknownPlatform) {
static const char tbd_v1_file_unknown_platform[] = "---\n"
"archs: [ i386 ]\n"
"platform: newOS\n"
"...\n";
static const char TBDv1FileUnknownPlatform[] = "---\n"
"archs: [ i386 ]\n"
"platform: newOS\n"
"...\n";
auto Result = TextAPIReader::get(
MemoryBufferRef(tbd_v1_file_unknown_platform, "Test.tbd"));
auto Result =
TextAPIReader::get(MemoryBufferRef(TBDv1FileUnknownPlatform, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
@ -422,13 +414,13 @@ TEST(TBDv1, UnknownPlatform) {
}
TEST(TBDv1, MalformedFile1) {
static const char malformed_file1[] = "---\n"
"archs: [ arm64 ]\n"
"foobar: \"Unsupported key\"\n"
"...\n";
static const char TBDv1FileMalformed1[] = "---\n"
"archs: [ arm64 ]\n"
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(malformed_file1, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv1FileMalformed1, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
@ -437,15 +429,15 @@ TEST(TBDv1, MalformedFile1) {
}
TEST(TBDv1, MalformedFile2) {
static const char malformed_file2[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"foobar: \"Unsupported key\"\n"
"...\n";
static const char TBDv1FileMalformed2[] = "---\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(malformed_file2, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv1FileMalformed2, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
ASSERT_EQ(

View File

@ -40,7 +40,7 @@ static ExportedSymbol TBDv2Symbols[] = {
namespace TBDv2 {
TEST(TBDv2, ReadFile) {
static const char tbd_v2_file1[] =
static const char TBDv2File1[] =
"--- !tapi-tbd-v2\n"
"archs: [ armv7, armv7s, armv7k, arm64 ]\n"
"platform: ios\n"
@ -67,7 +67,7 @@ TEST(TBDv2, ReadFile) {
" thread-local-symbols: [ _tlv3 ]\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v2_file1, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2File1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
@ -110,7 +110,7 @@ TEST(TBDv2, ReadFile) {
}
TEST(TBDv2, ReadFile2) {
static const char tbd_v2_file2[] =
static const char TBDv2File2[] =
"--- !tapi-tbd-v2\n"
"archs: [ armv7, armv7s, armv7k, arm64 ]\n"
"platform: ios\n"
@ -138,7 +138,7 @@ TEST(TBDv2, ReadFile2) {
" weak-ref-symbols: [ _undefWeak1, _undefWeak2 ]\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v2_file2, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2File2, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
@ -163,7 +163,7 @@ TEST(TBDv2, ReadFile2) {
}
TEST(TBDv2, WriteFile) {
static const char tbd_v2_file3[] =
static const char TBDv2File3[] =
"--- !tapi-tbd-v2\n"
"archs: [ i386, x86_64 ]\n"
"platform: macosx\n"
@ -213,18 +213,18 @@ TEST(TBDv2, WriteFile) {
raw_svector_ostream OS(Buffer);
auto Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(tbd_v2_file3, Buffer.c_str());
EXPECT_STREQ(TBDv2File3, Buffer.c_str());
}
TEST(TBDv2, Platform_macOS) {
static const char tbd_v2_platform_macos[] = "--- !tapi-tbd-v2\n"
"archs: [ x86_64 ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv2PlatformMacOS[] = "--- !tapi-tbd-v2\n"
"archs: [ x86_64 ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_platform_macos, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv2PlatformMacOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
auto Platform = PlatformKind::macOS;
@ -234,14 +234,14 @@ TEST(TBDv2, Platform_macOS) {
}
TEST(TBDv2, Platform_iOS) {
static const char tbd_v2_platform_ios[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv2PlatformiOS[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_platform_ios, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv2PlatformiOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::iOS;
auto File = std::move(Result.get());
@ -251,14 +251,14 @@ TEST(TBDv2, Platform_iOS) {
}
TEST(TBDv2, Platform_watchOS) {
static const char tbd_v2_platform_watchos[] = "--- !tapi-tbd-v2\n"
"archs: [ armv7k ]\n"
"platform: watchos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv2PlatformWatchOS[] = "--- !tapi-tbd-v2\n"
"archs: [ armv7k ]\n"
"platform: watchos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_platform_watchos, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv2PlatformWatchOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::watchOS;
auto File = std::move(Result.get());
@ -268,14 +268,14 @@ TEST(TBDv2, Platform_watchOS) {
}
TEST(TBDv2, Platform_tvOS) {
static const char tbd_v2_platform_tvos[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: tvos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv2PlatformtvOS[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: tvos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_platform_tvos, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv2PlatformtvOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::tvOS;
auto File = std::move(Result.get());
@ -285,14 +285,13 @@ TEST(TBDv2, Platform_tvOS) {
}
TEST(TBDv2, Platform_bridgeOS) {
static const char tbd_v2_platform_bridgeos[] = "--- !tapi-tbd-v2\n"
"archs: [ armv7k ]\n"
"platform: bridgeos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv2BridgeOS[] = "--- !tapi-tbd-v2\n"
"archs: [ armv7k ]\n"
"platform: bridgeos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_platform_bridgeos, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2BridgeOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::bridgeOS;
auto File = std::move(Result.get());
@ -302,15 +301,14 @@ TEST(TBDv2, Platform_bridgeOS) {
}
TEST(TBDv2, Swift_1_0) {
static const char tbd_v2_swift_1_0[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 1.0\n"
"...\n";
static const char TBDv2Swift1[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 1.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_1_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
@ -318,15 +316,14 @@ TEST(TBDv2, Swift_1_0) {
}
TEST(TBDv2, Swift_1_1) {
static const char tbd_v2_swift_1_1[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 1.1\n"
"...\n";
static const char TBDv2Swift1dot[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 1.1\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_1_1, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift1dot, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
@ -350,15 +347,14 @@ TEST(TBDv2, Swift_2_0) {
}
TEST(TBDv2, Swift_3_0) {
static const char tbd_v2_swift_3_0[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 3.0\n"
"...\n";
static const char TBDv2Swift3[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 3.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_3_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift3, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
@ -366,15 +362,14 @@ TEST(TBDv2, Swift_3_0) {
}
TEST(TBDv2, Swift_4_0) {
static const char tbd_v2_swift_4_0[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 4.0\n"
"...\n";
static const char TBDv2Swift4[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 4.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_4_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift4, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:5:16: error: invalid Swift ABI "
@ -383,14 +378,14 @@ TEST(TBDv2, Swift_4_0) {
}
TEST(TBDv2, Swift_5) {
static const char tbd_v2_swift_5[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 5\n"
"...\n";
static const char TBDv2Swift5[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 5\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_5, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift5, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
@ -398,15 +393,14 @@ TEST(TBDv2, Swift_5) {
}
TEST(TBDv2, Swift_99) {
static const char tbd_v2_swift_99[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 99\n"
"...\n";
static const char TBDv2Swift99[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-version: 99\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_99, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift99, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
@ -414,25 +408,24 @@ TEST(TBDv2, Swift_99) {
}
TEST(TBDv2, UnknownArchitecture) {
static const char tbd_v2_file_unknown_architecture[] =
"--- !tapi-tbd-v2\n"
"archs: [ foo ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(
MemoryBufferRef(tbd_v2_file_unknown_architecture, "Test.tbd"));
static const char TBDv2FileUnknownArch[] = "--- !tapi-tbd-v2\n"
"archs: [ foo ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(TBDv2FileUnknownArch, "Test.tbd"));
EXPECT_TRUE(!!Result);
}
TEST(TBDv2, UnknownPlatform) {
static const char tbd_v2_file_unknown_platform[] = "--- !tapi-tbd-v2\n"
"archs: [ i386 ]\n"
"platform: newOS\n"
"...\n";
static const char TBDv2FileUnknownPlatform[] = "--- !tapi-tbd-v2\n"
"archs: [ i386 ]\n"
"platform: newOS\n"
"...\n";
auto Result = TextAPIReader::get(
MemoryBufferRef(tbd_v2_file_unknown_platform, "Test.tbd"));
auto Result =
TextAPIReader::get(MemoryBufferRef(TBDv2FileUnknownPlatform, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
@ -441,15 +434,14 @@ TEST(TBDv2, UnknownPlatform) {
}
TEST(TBDv2, InvalidPlatform) {
static const char tbd_v2_file_invalid_platform[] =
"--- !tapi-tbd-v2\n"
"archs: [ i386 ]\n"
"platform: iosmac\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv2FileInvalidPlatform[] = "--- !tapi-tbd-v2\n"
"archs: [ i386 ]\n"
"platform: iosmac\n"
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(
MemoryBufferRef(tbd_v2_file_invalid_platform, "Test.tbd"));
auto Result =
TextAPIReader::get(MemoryBufferRef(TBDv2FileInvalidPlatform, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: invalid platform\nplatform: "
@ -458,13 +450,13 @@ TEST(TBDv2, InvalidPlatform) {
}
TEST(TBDv2, MalformedFile1) {
static const char malformed_file1[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"foobar: \"Unsupported key\"\n"
"...\n";
static const char TBDv2FileMalformed1[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(malformed_file1, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv2FileMalformed1, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
@ -473,15 +465,15 @@ TEST(TBDv2, MalformedFile1) {
}
TEST(TBDv2, MalformedFile2) {
static const char malformed_file2[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"foobar: \"Unsupported key\"\n"
"...\n";
static const char TBDv2FileMalformed2[] = "--- !tapi-tbd-v2\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(malformed_file2, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv2FileMalformed2, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
ASSERT_EQ(

View File

@ -40,7 +40,7 @@ static ExportedSymbol TBDv3Symbols[] = {
namespace TBDv3 {
TEST(TBDv3, ReadFile) {
static const char tbd_v3_file1[] =
static const char TBDv3File1[] =
"--- !tapi-tbd-v3\n"
"archs: [ armv7, arm64 ]\n"
"uuids: [ 'armv7: 00000000-0000-0000-0000-000000000000',\n"
@ -70,7 +70,7 @@ TEST(TBDv3, ReadFile) {
" thread-local-symbols: [ _tlv3 ]\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v3_file1, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3File1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
@ -118,7 +118,7 @@ TEST(TBDv3, ReadFile) {
}
TEST(TBDv3, WriteFile) {
static const char tbd_v3_file3[] =
static const char TBDv3File3[] =
"--- !tapi-tbd-v3\n"
"archs: [ i386, x86_64 ]\n"
"platform: macosx\n"
@ -168,18 +168,18 @@ TEST(TBDv3, WriteFile) {
raw_svector_ostream OS(Buffer);
auto Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(tbd_v3_file3, Buffer.c_str());
EXPECT_STREQ(TBDv3File3, Buffer.c_str());
}
TEST(TBDv3, Platform_macOS) {
static const char tbd_v3_platform_macos[] = "--- !tapi-tbd-v3\n"
"archs: [ x86_64 ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3PlatformMacOS[] = "--- !tapi-tbd-v3\n"
"archs: [ x86_64 ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_platform_macos, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformMacOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::macOS;
auto File = std::move(Result.get());
@ -191,19 +191,19 @@ TEST(TBDv3, Platform_macOS) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_platform_macos),
EXPECT_EQ(stripWhitespace(TBDv3PlatformMacOS),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Platform_iOS) {
static const char tbd_v3_platform_ios[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3PlatformiOS[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_platform_ios, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformiOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::iOS;
auto File = std::move(Result.get());
@ -215,19 +215,17 @@ TEST(TBDv3, Platform_iOS) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_platform_ios),
stripWhitespace(Buffer.c_str()));
EXPECT_EQ(stripWhitespace(TBDv3PlatformiOS), stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Platform_watchOS) {
static const char tbd_v3_platform_watchos[] = "--- !tapi-tbd-v3\n"
"archs: [ armv7k ]\n"
"platform: watchos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3watchOS[] = "--- !tapi-tbd-v3\n"
"archs: [ armv7k ]\n"
"platform: watchos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_platform_watchos, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3watchOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::watchOS;
auto File = std::move(Result.get());
@ -239,19 +237,18 @@ TEST(TBDv3, Platform_watchOS) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_platform_watchos),
stripWhitespace(Buffer.c_str()));
EXPECT_EQ(stripWhitespace(TBDv3watchOS), stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Platform_tvOS) {
static const char tbd_v3_platform_tvos[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: tvos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3PlatformtvOS[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: tvos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_platform_tvos, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformtvOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
auto Platform = PlatformKind::tvOS;
@ -263,19 +260,18 @@ TEST(TBDv3, Platform_tvOS) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_platform_tvos),
EXPECT_EQ(stripWhitespace(TBDv3PlatformtvOS),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Platform_bridgeOS) {
static const char tbd_v3_platform_bridgeos[] = "--- !tapi-tbd-v3\n"
"archs: [ armv7k ]\n"
"platform: bridgeos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3BridgeOS[] = "--- !tapi-tbd-v3\n"
"archs: [ armv7k ]\n"
"platform: bridgeos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_platform_bridgeos, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3BridgeOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::bridgeOS;
auto File = std::move(Result.get());
@ -287,19 +283,18 @@ TEST(TBDv3, Platform_bridgeOS) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_platform_bridgeos),
stripWhitespace(Buffer.c_str()));
EXPECT_EQ(stripWhitespace(TBDv3BridgeOS), stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Platform_macCatalyst) {
static const char tbd_v3_platform_iosmac[] = "--- !tapi-tbd-v3\n"
"archs: [ armv7k ]\n"
"platform: iosmac\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3PlatformiOSmac[] = "--- !tapi-tbd-v3\n"
"archs: [ armv7k ]\n"
"platform: iosmac\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_platform_iosmac, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformiOSmac, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::macCatalyst;
auto File = std::move(Result.get());
@ -310,18 +305,19 @@ TEST(TBDv3, Platform_macCatalyst) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_platform_iosmac), stripWhitespace(Buffer.c_str()));
EXPECT_EQ(stripWhitespace(TBDv3PlatformiOSmac),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Platform_zippered) {
static const char tbd_v3_platform_zip[] = "--- !tapi-tbd-v3\n"
"archs: [ armv7k ]\n"
"platform: zippered\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3PlatformZippered[] = "--- !tapi-tbd-v3\n"
"archs: [ armv7k ]\n"
"platform: zippered\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_platform_zip, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformZippered, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
@ -337,19 +333,19 @@ TEST(TBDv3, Platform_zippered) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_platform_zip),
EXPECT_EQ(stripWhitespace(TBDv3PlatformZippered),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Platform_iOSSim) {
static const char tbd_v3_platform_iossim[] = "--- !tapi-tbd-v3\n"
"archs: [ x86_64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3PlatformiOSsim[] = "--- !tapi-tbd-v3\n"
"archs: [ x86_64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_platform_iossim, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformiOSsim, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::iOSSimulator;
auto File = std::move(Result.get());
@ -361,19 +357,19 @@ TEST(TBDv3, Platform_iOSSim) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_platform_iossim),
EXPECT_EQ(stripWhitespace(TBDv3PlatformiOSsim),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Platform_watchOSSim) {
static const char tbd_v3_platform_watchossim[] = "--- !tapi-tbd-v3\n"
"archs: [ x86_64 ]\n"
"platform: watchos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3watchOSsim[] = "--- !tapi-tbd-v3\n"
"archs: [ x86_64 ]\n"
"platform: watchos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(
MemoryBufferRef(tbd_v3_platform_watchossim, "Test.tbd"));
auto Result =
TextAPIReader::get(MemoryBufferRef(TBDv3watchOSsim, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::watchOSSimulator;
auto File = std::move(Result.get());
@ -385,19 +381,18 @@ TEST(TBDv3, Platform_watchOSSim) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_platform_watchossim),
stripWhitespace(Buffer.c_str()));
EXPECT_EQ(stripWhitespace(TBDv3watchOSsim), stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Platform_tvOSSim) {
static const char tbd_v3_platform_tvossim[] = "--- !tapi-tbd-v3\n"
"archs: [ x86_64 ]\n"
"platform: tvos\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3PlatformtvOSsim[] = "--- !tapi-tbd-v3\n"
"archs: [ x86_64 ]\n"
"platform: tvos\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_platform_tvossim, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformtvOSsim, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
auto Platform = PlatformKind::tvOSSimulator;
@ -409,20 +404,19 @@ TEST(TBDv3, Platform_tvOSSim) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_platform_tvossim),
EXPECT_EQ(stripWhitespace(TBDv3PlatformtvOSsim),
stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Swift_1_0) {
static const char tbd_v3_swift_1_0[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 1.0\n"
"...\n";
static const char TBDv3Swift1[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 1.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_swift_1_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
@ -432,19 +426,18 @@ TEST(TBDv3, Swift_1_0) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_swift_1_0), stripWhitespace(Buffer.c_str()));
EXPECT_EQ(stripWhitespace(TBDv3Swift1), stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Swift_1_1) {
static const char tbd_v3_swift_1_1[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 1.1\n"
"...\n";
static const char TBDv3Swift1Dot[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 1.1\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_swift_1_1, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift1Dot, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
@ -454,19 +447,18 @@ TEST(TBDv3, Swift_1_1) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_swift_1_1), stripWhitespace(Buffer.c_str()));
EXPECT_EQ(stripWhitespace(TBDv3Swift1Dot), stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Swift_2_0) {
static const char tbd_v3_swift_2_0[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 2.0\n"
"...\n";
static const char TBDv3Swift2[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 2.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_swift_2_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift2, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
@ -476,19 +468,18 @@ TEST(TBDv3, Swift_2_0) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_swift_2_0), stripWhitespace(Buffer.c_str()));
EXPECT_EQ(stripWhitespace(TBDv3Swift2), stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Swift_3_0) {
static const char tbd_v3_swift_3_0[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 3.0\n"
"...\n";
static const char TBDv3Swift3[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 3.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_swift_3_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift3, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
@ -498,19 +489,18 @@ TEST(TBDv3, Swift_3_0) {
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(tbd_v3_swift_3_0), stripWhitespace(Buffer.c_str()));
EXPECT_EQ(stripWhitespace(TBDv3Swift3), stripWhitespace(Buffer.c_str()));
}
TEST(TBDv3, Swift_4_0) {
static const char tbd_v3_swift_4_0[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 4.0\n"
"...\n";
static const char TBDv3Swift4[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 4.0\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_swift_4_0, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift4, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:5:20: error: invalid Swift ABI "
@ -519,14 +509,14 @@ TEST(TBDv3, Swift_4_0) {
}
TEST(TBDv3, Swift_5) {
static const char tbd_v3_swift_5[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 5\n"
"...\n";
static const char TBDv3Swift5[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 5\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v3_swift_5, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift5, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
@ -534,15 +524,14 @@ TEST(TBDv3, Swift_5) {
}
TEST(TBDv3, Swift_99) {
static const char tbd_v3_swift_99[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 99\n"
"...\n";
static const char TBDv3Swift99[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"swift-abi-version: 99\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(tbd_v3_swift_99, "Test.tbd"));
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift99, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
@ -550,26 +539,25 @@ TEST(TBDv3, Swift_99) {
}
TEST(TBDv3, UnknownArchitecture) {
static const char tbd_v3_file_unknown_architecture[] =
"--- !tapi-tbd-v3\n"
"archs: [ foo ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
static const char TBDv3FileUnknownArch[] = "--- !tapi-tbd-v3\n"
"archs: [ foo ]\n"
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(
MemoryBufferRef(tbd_v3_file_unknown_architecture, "Test.tbd"));
auto Result =
TextAPIReader::get(MemoryBufferRef(TBDv3FileUnknownArch, "Test.tbd"));
EXPECT_TRUE(!!Result);
}
TEST(TBDv3, UnknownPlatform) {
static const char tbd_v3_file_unknown_platform[] = "--- !tapi-tbd-v3\n"
"archs: [ i386 ]\n"
"platform: newOS\n"
"...\n";
static const char TBDv3FileUnknownPlatform[] = "--- !tapi-tbd-v3\n"
"archs: [ i386 ]\n"
"platform: newOS\n"
"...\n";
auto Result = TextAPIReader::get(
MemoryBufferRef(tbd_v3_file_unknown_platform, "Test.tbd"));
auto Result =
TextAPIReader::get(MemoryBufferRef(TBDv3FileUnknownPlatform, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
@ -578,13 +566,13 @@ TEST(TBDv3, UnknownPlatform) {
}
TEST(TBDv3, MalformedFile1) {
static const char malformed_file1[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"foobar: \"Unsupported key\"\n"
"...\n";
static const char TBDv3FileMalformed1[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(malformed_file1, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv3FileMalformed1, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
@ -593,15 +581,15 @@ TEST(TBDv3, MalformedFile1) {
}
TEST(TBDv3, MalformedFile2) {
static const char malformed_file2[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"foobar: \"Unsupported key\"\n"
"...\n";
static const char TBDv3FileMalformed2[] = "--- !tapi-tbd-v3\n"
"archs: [ arm64 ]\n"
"platform: ios\n"
"install-name: Test.dylib\n"
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
TextAPIReader::get(MemoryBufferRef(malformed_file2, "Test.tbd"));
TextAPIReader::get(MemoryBufferRef(TBDv3FileMalformed2, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
ASSERT_EQ(