Skip to content

Commit 16a6805

Browse files
authored
Add test for sliced Data
1 parent d2b61e0 commit 16a6805

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Tests/CBORCodingTests/CBORParserTests.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CBORParserTests: XCTestCase {
2222
// Test Examples taken from Appendix A of RFC 7049
2323

2424
var value: Any!
25-
25+
2626
XCTAssertNoThrow(value = try CBORParser.parse(convertFromHexString("0x00")))
2727
XCTAssertTrue(value is UInt64)
2828
XCTAssertEqual(value as! UInt64, 0)
@@ -1075,6 +1075,18 @@ class CBORParserTests: XCTestCase {
10751075

10761076
XCTAssertThrowsError(try CBORParser.testCreateCodingKey(from: UInt64.max))
10771077
}
1078+
1079+
func testSlicedDataInput() {
1080+
var value: Any!
1081+
1082+
// Skip over the first 2 bytes with a slice.
1083+
let data = convertFromHexString("0x000000")[2...]
1084+
1085+
XCTAssertNoThrow(value = try CBORParser.parse(data))
1086+
XCTAssertTrue(value is UInt64)
1087+
XCTAssertEqual(value as! UInt64, 0)
1088+
1089+
}
10781090

10791091
// MARK: Private Methods
10801092

0 commit comments

Comments
 (0)