22//
33// This source file is part of the Swift W3C Trace Context open source project
44//
5- // Copyright (c) YEARS Moritz Lang and the Swift W3C Trace Context project authors
5+ // Copyright (c) 2020 Moritz Lang and the Swift W3C Trace Context project authors
66// Licensed under Apache License v2.0
77//
88// See LICENSE.txt for license information
@@ -57,13 +57,23 @@ final class TraceParentRawRepresentableTests: XCTestCase {
5757 XCTAssertEqual ( traceParent. rawValue, " 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01 " )
5858 }
5959
60+ func testDecodeFailsWithTooLongRawValue( ) {
61+ let rawValue = String ( repeating: " 42 " , count: 1000 )
62+ XCTAssertUninitializedTraceParent ( rawValue)
63+ }
64+
65+ func testDecodeFailsWithTooShortRawValue( ) {
66+ let rawValue = " too-short "
67+ XCTAssertUninitializedTraceParent ( rawValue)
68+ }
69+
6070 func testDecodeFailsWithTooManyComponents( ) {
61- let rawValue = " 00-0af7651916cd43dd8448eb211c80319c -b7ad6b7169203331-01-additional-components "
71+ let rawValue = " 00-0af7651916cd43dd8448eb211c803 -b7ad6b7169203331-01-12 "
6272 XCTAssertUninitializedTraceParent ( rawValue)
6373 }
6474
6575 func testDecodeFailsWithTooFewComponents( ) {
66- let rawValue = " 00-0af7651916cd43dd8448eb211c80319c "
76+ let rawValue = " 00-0af7651916cd43dd8448eb211c803-b7ad6b7169203331000000 "
6777 XCTAssertUninitializedTraceParent ( rawValue)
6878 }
6979
@@ -78,7 +88,7 @@ final class TraceParentRawRepresentableTests: XCTestCase {
7888 }
7989
8090 func testDecodeFailsWithTooShortTraceID( ) {
81- let rawValue = " 00-tooshort-b7ad6b7169203331-01 "
91+ let rawValue = " 00-tooshort-b7ad6b7169203331-01432436432435434234234234 "
8292 XCTAssertUninitializedTraceParent ( rawValue)
8393 }
8494
@@ -88,7 +98,7 @@ final class TraceParentRawRepresentableTests: XCTestCase {
8898 }
8999
90100 func testDecodeFailsWithTooShortParentID( ) {
91- let rawValue = " 00-0af7651916cd43dd8448eb211c80319c-tooshort-01 "
101+ let rawValue = " 00-0af7651916cd43dd8448eb211c80319c-tooshort-0131434343 "
92102 XCTAssertUninitializedTraceParent ( rawValue)
93103 }
94104
@@ -98,12 +108,12 @@ final class TraceParentRawRepresentableTests: XCTestCase {
98108 }
99109
100110 func testDecodeFailsWithTooLongTraceFlags( ) {
101- let rawValue = " 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331 -toolong "
111+ let rawValue = " 00-0af7651916cd43dd8448eb211c80319c-b7ad6b71692 -toolong "
102112 XCTAssertUninitializedTraceParent ( rawValue)
103113 }
104114
105115 func testDecodeFailsWithTooShortTraceFlags( ) {
106- let rawValue = " 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331 -0 "
116+ let rawValue = " 00-0af7651916cd43dd8448eb211c80319c-b7ad6b71692033311 -0 "
107117 XCTAssertUninitializedTraceParent ( rawValue)
108118 }
109119
0 commit comments