-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathByteRunLengthCoderTests.swift
More file actions
36 lines (32 loc) · 1.01 KB
/
Copy pathByteRunLengthCoderTests.swift
File metadata and controls
36 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// ByteRunLengthCoderTests.swift
// DMZTests
//
// Created by Brielle Harrison on 7/16/23.
//
import Foundation
import XCTest
@testable import DMZ
// Unit Test for the ByteRunLengthCoder
class ByteRunLengthCoderTests: XCTestCase {
func testEncode() {
let input: [UInt8] = [
0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05
]
let expectedOutput: [UInt8] = [
0x02, 0x01, 0x02, 0x02, 0x80, 0x03, 0x81, 0x04, 0x82, 0x05
]
let output = ByteRunLengthCoder.encode(data: input)
XCTAssertEqual(output, expectedOutput, "The encoded data is incorrect")
}
func testDecode() {
let input: [UInt8] = [
0x02, 0x01, 0x02, 0x02, 0x80, 0x03, 0x81, 0x04, 0x82, 0x05
]
let expectedOutput: [UInt8] = [
0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05
]
let output = ByteRunLengthCoder.decode(data: input)
XCTAssertEqual(output, expectedOutput, "The decoded data is incorrect")
}
}