-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convenience init for ParserError using NSError
- Loading branch information
1 parent
2130f79
commit 7babc5f
Showing
5 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// | ||
// ParserErrorTests.swift | ||
// | ||
// | ||
// Created by Robert Galluccio on 21/04/2021. | ||
// | ||
|
||
import Foundation | ||
import XCTest | ||
import SCTE35Parser | ||
|
||
class ParserErrorTests: XCTestCase { | ||
var expectedError: ParserError! | ||
|
||
func test_initFromNSError_encryptedMessageNotSupported() { | ||
expectedError = .encryptedMessageNotSupported | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_invalidATSCContentIdentifierInUPID() { | ||
expectedError = .invalidATSCContentIdentifierInUPID( | ||
InvalidATSCContentIdentifierInUPIDInfo(upidLength: 10) | ||
) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_invalidBitStreamMode() { | ||
expectedError = .invalidBitStreamMode(InvalidBitStreamModeErrorInfo(bsmod: 7, acmod: nil)) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_invalidInputString() { | ||
expectedError = .invalidInputString("!*&@$%?") | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_invalidMPUInSegmentationUPID() { | ||
expectedError = .invalidMPUInSegmentationUPID(InvalidMPUInSegmentationUPIDInfo(upidLength: 8)) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_invalidPrivateIndicator() { | ||
expectedError = .invalidPrivateIndicator | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_invalidSectionSyntaxIndicator() { | ||
expectedError = .invalidSectionSyntaxIndicator | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_invalidSegmentationDescriptorIdentifier() { | ||
expectedError = .invalidSegmentationDescriptorIdentifier(42) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_invalidURLInSegmentationUPID() { | ||
expectedError = .invalidURLInSegmentationUPID("") | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_invalidUUIDInSegmentationUPID() { | ||
expectedError = .invalidUUIDInSegmentationUPID("") | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_unexpectedEndOfData() { | ||
expectedError = .unexpectedEndOfData( | ||
UnexpectedEndOfDataErrorInfo( | ||
expectedMinimumBitsLeft: 100, | ||
actualBitsLeft: 50, | ||
description: "Oops" | ||
) | ||
) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_unexpectedSegmentationUPIDLength() { | ||
expectedError = .unexpectedSegmentationUPIDLength( | ||
UnexpectedSegmentationUPIDLengthErrorInfo( | ||
declaredSegmentationUPIDLength: 8, | ||
expectedSegmentationUPIDLength: 12, | ||
segmentationUPIDType: .ti | ||
) | ||
) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_unrecognisedAudioCodingMode() { | ||
expectedError = .unrecognisedAudioCodingMode(10) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_unrecognisedSegmentationTypeID() { | ||
expectedError = .unrecognisedSegmentationTypeID(0x55) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_unrecognisedSegmentationUPIDType() { | ||
expectedError = .unrecognisedSegmentationUPIDType(0x22) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_unrecognisedSpliceCommandType() { | ||
expectedError = .unrecognisedSpliceCommandType(0x10) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
|
||
func test_initFromNSError_unrecognisedSpliceDescriptorTag() { | ||
expectedError = .unrecognisedSpliceDescriptorTag(0x10) | ||
XCTAssertEqual(expectedError, ParserError(fromNSError: expectedError as NSError)) | ||
} | ||
} |