From 17bd85ba5d3d66daa2bf41b9e07f4e1b0da48940 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Wed, 29 Sep 2021 18:47:56 +0300 Subject: [PATCH] [Tests] Add a test for multiple concatenated LZ4 frames --- SWCompression.xcodeproj/project.pbxproj | 4 ++++ Tests/LZ4Tests.swift | 13 +++++++++++++ Tests/Test Files | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/SWCompression.xcodeproj/project.pbxproj b/SWCompression.xcodeproj/project.pbxproj index 2388ec0b..a0ba887e 100644 --- a/SWCompression.xcodeproj/project.pbxproj +++ b/SWCompression.xcodeproj/project.pbxproj @@ -260,6 +260,7 @@ E6974C5B2701AC2600E06C60 /* test_dict_B5_dictID.lz4 in Resources */ = {isa = PBXBuildFile; fileRef = E6974C5A2701AC2600E06C60 /* test_dict_B5_dictID.lz4 */; }; E6C4150726FE230A00F9D36F /* XxHash32.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6C4150626FE230A00F9D36F /* XxHash32.swift */; }; E6D86D2F26FE35C50032CFFA /* XxHash32Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D86D2E26FE35C50032CFFA /* XxHash32Tests.swift */; }; + E6DF9ECE2704BF14003BD91E /* test_multi_frame.lz4 in Resources */ = {isa = PBXBuildFile; fileRef = E6DF9ECD2704BF14003BD91E /* test_multi_frame.lz4 */; }; E6EDD6A826F7767F00884532 /* test_minor_version_3.7z in Resources */ = {isa = PBXBuildFile; fileRef = E6EDD6A626F7767E00884532 /* test_minor_version_3.7z */; }; E6EDD6A926F7767F00884532 /* test_minor_version_4.7z in Resources */ = {isa = PBXBuildFile; fileRef = E6EDD6A726F7767E00884532 /* test_minor_version_4.7z */; }; E6EDD6AC26F77C0E00884532 /* test_minor_version_2.7z in Resources */ = {isa = PBXBuildFile; fileRef = E6EDD6AB26F77C0E00884532 /* test_minor_version_2.7z */; }; @@ -530,6 +531,7 @@ E6974C5A2701AC2600E06C60 /* test_dict_B5_dictID.lz4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_dict_B5_dictID.lz4; sourceTree = ""; }; E6C4150626FE230A00F9D36F /* XxHash32.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XxHash32.swift; sourceTree = ""; }; E6D86D2E26FE35C50032CFFA /* XxHash32Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XxHash32Tests.swift; sourceTree = ""; }; + E6DF9ECD2704BF14003BD91E /* test_multi_frame.lz4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_multi_frame.lz4; sourceTree = ""; }; E6EDD6A626F7767E00884532 /* test_minor_version_3.7z */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_minor_version_3.7z; sourceTree = ""; }; E6EDD6A726F7767E00884532 /* test_minor_version_4.7z */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_minor_version_4.7z; sourceTree = ""; }; E6EDD6AB26F77C0E00884532 /* test_minor_version_2.7z */ = {isa = PBXFileReference; lastKnownFileType = file; path = test_minor_version_2.7z; sourceTree = ""; }; @@ -1046,6 +1048,7 @@ E652FEC527007E79006BC312 /* test8.lz4 */, E652FEC227007E78006BC312 /* test9.lz4 */, E652FED327007F2F006BC312 /* SWCompressionSourceCode.tar.lz4 */, + E6DF9ECD2704BF14003BD91E /* test_multi_frame.lz4 */, ); path = LZ4; sourceTree = ""; @@ -1206,6 +1209,7 @@ 06F066261FFB763400312A82 /* test4.answer in Resources */, 06F066481FFB763400312A82 /* SWCompressionSourceCode.zip in Resources */, 06F0665D1FFB763400312A82 /* test8.lzma in Resources */, + E6DF9ECE2704BF14003BD91E /* test_multi_frame.lz4 in Resources */, 06F0664F1FFB763400312A82 /* test_oldgnu.tar in Resources */, E604F3C22700C75F004BD38A /* test_dict_B5.lz4 in Resources */, E652FEE127009BDD006BC312 /* test4_legacy.lz4 in Resources */, diff --git a/Tests/LZ4Tests.swift b/Tests/LZ4Tests.swift index 9aea2ea5..3159ecc3 100644 --- a/Tests/LZ4Tests.swift +++ b/Tests/LZ4Tests.swift @@ -156,4 +156,17 @@ class LZ4Tests: XCTestCase { XCTAssertEqual(decompressedData, answerData) } + func testMultiFrameDecompress() throws { + // The test file contains three frames: + // - Legacy frame format, compressed test1.answer, + // - Skippable frame with 1233 bytes of random data, + // - Normal frame with compressed test4.answer. + let testData = try Constants.data(forTest: "test_multi_frame", withType: LZ4Tests.testType) + let result = try LZ4.multiDecompress(data: testData) + + XCTAssertEqual(result.count, 2) + XCTAssertEqual(result[0], try Constants.data(forAnswer: "test1")) + XCTAssertEqual(result[1], try Constants.data(forAnswer: "test4")) + } + } diff --git a/Tests/Test Files b/Tests/Test Files index 9f102c80..5e1f0ce6 160000 --- a/Tests/Test Files +++ b/Tests/Test Files @@ -1 +1 @@ -Subproject commit 9f102c806854876ff6fe7ef8efac2d4a28b8e7b2 +Subproject commit 5e1f0ce6cc4e57ed0cc8c8166470dad0e52e86de