Skip to content

Commit 4fa84e0

Browse files
committed
[Tests] Add small string tests for Deflate
1 parent 06adf52 commit 4fa84e0

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Tests/BZip2CompressionTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class BZip2CompressionTests: XCTestCase {
2929
}
3030

3131
func testBZip2CompressStrings() throws {
32+
try stringTest("ban")
3233
try stringTest("banana")
3334
try stringTest("abaaba")
3435
try stringTest("abracadabra")

Tests/DeflateCompressionTests.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ class DeflateCompressionTests: XCTestCase {
1919
}
2020
}
2121

22+
func stringTest(_ string: String) throws {
23+
let answerData = Data(string.utf8)
24+
let compressedData = Deflate.compress(data: answerData)
25+
let redecompressedData = try Deflate.decompress(data: compressedData)
26+
XCTAssertEqual(redecompressedData, answerData)
27+
}
28+
29+
func testDeflateCompressStrings() throws {
30+
try stringTest("ban")
31+
try stringTest("banana")
32+
try stringTest("abaaba")
33+
try stringTest("abracadabra")
34+
try stringTest("cabbage")
35+
try stringTest("baabaabac")
36+
try stringTest("AAAAAAABBBBCCCD")
37+
try stringTest("AAAAAAA")
38+
try stringTest("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890")
39+
}
40+
2241
func testDeflate1() throws {
2342
try self.answerTest("test1")
2443
}

0 commit comments

Comments
 (0)