File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Tests/BinaryParseKitTests Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // TestMatchable.swift
3+ // BinaryParseKit
4+ //
5+ // Created by Larry Zeng on 11/22/25.
6+ //
7+
8+ import BinaryParseKit
9+ import Testing
10+
11+ extension String : Matchable {
12+ public func bytesToMatch( ) -> [ UInt8 ] {
13+ utf8. map ( \. self)
14+ }
15+ }
16+
17+ @Suite
18+ struct MatchableTests {
19+ enum RawRepresentableMatch : UInt8 , Matchable , Codable {
20+ case success = 0x00
21+ case failure = 0x01
22+ }
23+
24+ @Test ( arguments: [
25+ RawRepresentableMatch . success,
26+ . failure,
27+ ] )
28+ func `byte generated from RawRepresentable`(_ input: RawRepresentableMatch) {
29+ #expect( input. bytesToMatch( ) == [ input. rawValue] )
30+ }
31+
32+ enum CustomRawRepresentable : String , Matchable , Codable {
33+ case first = " one "
34+ case second = " two "
35+ case third = " three "
36+ }
37+
38+ @Test ( arguments: [
39+ CustomRawRepresentable . first,
40+ . second,
41+ . third,
42+ ] )
43+ func `bytes generated from CustomRawRepresentable`(_ input: CustomRawRepresentable) {
44+ #expect( input. bytesToMatch( ) == Array( input. rawValue. utf8 ) )
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments