Skip to content

Commit

Permalink
add Snippet testing edge cases with system gzip utility
Browse files Browse the repository at this point in the history
  • Loading branch information
tayloraswift committed Apr 3, 2024
1 parent c7080fe commit 7931e89
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Snippets/LZ77/BasicGzip.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import LZ77
import PNG
// snippet.ARCHIVE
let text:String = "hello barbie"

Expand All @@ -9,3 +10,14 @@ let archive:[UInt8] = Gzip.archive(
let utf8:[UInt8] = try Gzip.extract(from: archive[...])
// snippet.end
precondition(utf8.elementsEqual(text.utf8))

let path:String = "Sources/LZ77/docs.docc/GzipCompression"
// snippet.EDGE_CASES
let _:Void? = System.File.Destination.open(path: "\(path)/empty.gz")
{
$0.write(Gzip.archive(bytes: [][...], level: 10))
}
let _:Void? = System.File.Destination.open(path: "\(path)/single-byte.gz")
{
$0.write(Gzip.archive(bytes: [0x0A][...], level: 10))
}
Binary file added Sources/LZ77/docs.docc/GzipCompression/empty.gz
Binary file not shown.
Binary file not shown.

0 comments on commit 7931e89

Please sign in to comment.