Skip to content

Commit c496e0c

Browse files
committed
Fixed unit test build issues with Xcode 16.3
1 parent 4f5711a commit c496e0c

9 files changed

Lines changed: 68 additions & 67 deletions

Tests/PrefsKitCoreTests/ChainingEncodingStrategiesTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct ChainingEncodingStrategiesTests {
7171

7272
schema.fpsA = .plus
7373

74-
#expect(schema.storage.storageValue<Int>(forKey: "fpsA") == FloatingPointSign.plus.rawValue)
74+
#expect(schema.storage.storageValue(forKey: "fpsA") as Int? == FloatingPointSign.plus.rawValue)
7575
#expect(schema.fpsA == .plus)
7676
}
7777

@@ -82,7 +82,7 @@ struct ChainingEncodingStrategiesTests {
8282

8383
schema.fpsB = .plus
8484

85-
#expect(schema.storage.storageValue<String>(forKey: "fpsB") == String(FloatingPointSign.plus.rawValue))
85+
#expect(schema.storage.storageValue(forKey: "fpsB") as String? == String(FloatingPointSign.plus.rawValue))
8686
#expect(schema.fpsB == .plus)
8787
}
8888
}

Tests/PrefsKitCoreTests/PrefsCodable Strategies/Base64StringDataPrefsCodingTests.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ struct Base64StringDataPrefsCodingTests {
3939
let testData = Data([0x01, 0x02, 0x03])
4040

4141
schema.data = testData
42-
#expect(schema.storage.storageValue<String>(forKey: "data") == "AQID")
42+
let getString: String = try #require(schema.storage.storageValue(forKey: "data"))
43+
#expect(getString == "AQID")
4344
#expect(schema.data == testData)
4445
}
4546

@@ -51,7 +52,7 @@ struct Base64StringDataPrefsCodingTests {
5152
let testType = MyType(id: 123, name: "foo")
5253

5354
schema.myTypeChained = testType
54-
let getString: String = try #require(schema.storage.storageValue<String>(forKey: "myTypeChained"))
55+
let getString: String = try #require(schema.storage.storageValue(forKey: "myTypeChained"))
5556
// just check for non-empty content, we won't check actual content since it's not fully deterministic
5657
#expect(getString.count > 10)
5758
#expect(schema.myTypeChained == testType)

Tests/PrefsKitCoreTests/PrefsCodable Strategies/BoolIntegerPrefCodingTests.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ struct BoolIntegerPrefCodingTests {
6060
let schema = TestSchema()
6161

6262
schema.boolIntStrict = true
63-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntStrict") == 1)
63+
#expect(schema.storage.storageValue(forKey: "boolIntStrict") as Int? == 1)
6464
#expect(schema.boolIntStrict == true)
6565

6666
schema.boolIntStrict = false
67-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntStrict") == 0)
67+
#expect(schema.storage.storageValue(forKey: "boolIntStrict") as Int? == 0)
6868
#expect(schema.boolIntStrict == false)
6969

7070
schema.storage.setStorageValue(forKey: "boolIntStrict", to: 2) // > 1
71-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntStrict") == 2)
71+
#expect(schema.storage.storageValue(forKey: "boolIntStrict") as Int? == 2)
7272
#expect(schema.boolIntStrict == nil)
7373

7474
schema.storage.setStorageValue(forKey: "boolIntStrict", to: -1) // < 0
75-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntStrict") == -1)
75+
#expect(schema.storage.storageValue(forKey: "boolIntStrict") as Int? == -1)
7676
#expect(schema.boolIntStrict == nil)
7777
}
7878

@@ -82,19 +82,19 @@ struct BoolIntegerPrefCodingTests {
8282
let schema = TestSchema()
8383

8484
schema.boolIntNearest = true
85-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntNearest") == 1)
85+
#expect(schema.storage.storageValue(forKey: "boolIntNearest") as Int? == 1)
8686
#expect(schema.boolIntNearest == true)
8787

8888
schema.boolIntNearest = false
89-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntNearest") == 0)
89+
#expect(schema.storage.storageValue(forKey: "boolIntNearest") as Int? == 0)
9090
#expect(schema.boolIntNearest == false)
9191

9292
schema.storage.setStorageValue(forKey: "boolIntNearest", to: 2) // > 1
93-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntNearest") == 2)
93+
#expect(schema.storage.storageValue(forKey: "boolIntNearest") as Int? == 2)
9494
#expect(schema.boolIntNearest == true)
9595

9696
schema.storage.setStorageValue(forKey: "boolIntNearest", to: -1) // < 0
97-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntNearest") == -1)
97+
#expect(schema.storage.storageValue(forKey: "boolIntNearest") as Int? == -1)
9898
#expect(schema.boolIntNearest == false)
9999
}
100100

@@ -106,19 +106,19 @@ struct BoolIntegerPrefCodingTests {
106106
let schema = TestSchema()
107107

108108
schema.boolIntStrictChained = .yes
109-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntStrictChained") == 1)
109+
#expect(schema.storage.storageValue(forKey: "boolIntStrictChained") as Int? == 1)
110110
#expect(schema.boolIntStrictChained == .yes)
111111

112112
schema.boolIntStrictChained = .no
113-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntStrictChained") == 0)
113+
#expect(schema.storage.storageValue(forKey: "boolIntStrictChained") as Int? == 0)
114114
#expect(schema.boolIntStrictChained == .no)
115115

116116
schema.storage.setStorageValue(forKey: "boolIntStrictChained", to: 2) // > 1
117-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntStrictChained") == 2)
117+
#expect(schema.storage.storageValue(forKey: "boolIntStrictChained") as Int? == 2)
118118
#expect(schema.boolIntStrict == nil)
119119

120120
schema.storage.setStorageValue(forKey: "boolIntStrictChained", to: -1) // < 0
121-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntStrictChained") == -1)
121+
#expect(schema.storage.storageValue(forKey: "boolIntStrictChained") as Int? == -1)
122122
#expect(schema.boolIntStrict == nil)
123123
}
124124

@@ -128,19 +128,19 @@ struct BoolIntegerPrefCodingTests {
128128
let schema = TestSchema()
129129

130130
schema.boolIntNearestChained = .yes
131-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntNearestChained") == 1)
131+
#expect(schema.storage.storageValue(forKey: "boolIntNearestChained") as Int? == 1)
132132
#expect(schema.boolIntNearestChained == .yes)
133133

134134
schema.boolIntNearestChained = .no
135-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntNearestChained") == 0)
135+
#expect(schema.storage.storageValue(forKey: "boolIntNearestChained") as Int? == 0)
136136
#expect(schema.boolIntNearestChained == .no)
137137

138138
schema.storage.setStorageValue(forKey: "boolIntNearestChained", to: 2) // > 1
139-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntNearestChained") == 2)
139+
#expect(schema.storage.storageValue(forKey: "boolIntNearestChained") as Int? == 2)
140140
#expect(schema.boolIntNearestChained == .yes)
141141

142142
schema.storage.setStorageValue(forKey: "boolIntNearestChained", to: -1) // < 0
143-
#expect(schema.storage.storageValue<Int>(forKey: "boolIntNearestChained") == -1)
143+
#expect(schema.storage.storageValue(forKey: "boolIntNearestChained") as Int? == -1)
144144
#expect(schema.boolIntNearestChained == .no)
145145
}
146146
}

Tests/PrefsKitCoreTests/PrefsCodable Strategies/BoolStringPrefsCodingTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ struct BoolStringPrefsCodingTests {
6262
let schema = TestSchema()
6363

6464
schema.boolStringTrueFalseCapitalized = true
65-
#expect(schema.storage.storageValue<String>(forKey: "boolStringTrueFalseCapitalized") == "True")
65+
#expect(schema.storage.storageValue(forKey: "boolStringTrueFalseCapitalized") as String? == "True")
6666
#expect(schema.boolStringTrueFalseCapitalized == true)
6767

6868
schema.boolStringTrueFalseCapitalized = false
69-
#expect(schema.storage.storageValue<String>(forKey: "boolStringTrueFalseCapitalized") == "False")
69+
#expect(schema.storage.storageValue(forKey: "boolStringTrueFalseCapitalized") as String? == "False")
7070
#expect(schema.boolStringTrueFalseCapitalized == false)
7171
}
7272

@@ -76,11 +76,11 @@ struct BoolStringPrefsCodingTests {
7676
let schema = TestSchema()
7777

7878
schema.boolStringTrueFalseLowercase = true
79-
#expect(schema.storage.storageValue<String>(forKey: "boolStringTrueFalseLowercase") == "true")
79+
#expect(schema.storage.storageValue(forKey: "boolStringTrueFalseLowercase") as String? == "true")
8080
#expect(schema.boolStringTrueFalseLowercase == true)
8181

8282
schema.boolStringTrueFalseLowercase = false
83-
#expect(schema.storage.storageValue<String>(forKey: "boolStringTrueFalseLowercase") == "false")
83+
#expect(schema.storage.storageValue(forKey: "boolStringTrueFalseLowercase") as String? == "false")
8484
#expect(schema.boolStringTrueFalseLowercase == false)
8585
}
8686

@@ -90,11 +90,11 @@ struct BoolStringPrefsCodingTests {
9090
let schema = TestSchema()
9191

9292
schema.boolStringTrueFalseUppercase = true
93-
#expect(schema.storage.storageValue<String>(forKey: "boolStringTrueFalseUppercase") == "TRUE")
93+
#expect(schema.storage.storageValue(forKey: "boolStringTrueFalseUppercase") as String? == "TRUE")
9494
#expect(schema.boolStringTrueFalseUppercase == true)
9595

9696
schema.boolStringTrueFalseUppercase = false
97-
#expect(schema.storage.storageValue<String>(forKey: "boolStringTrueFalseUppercase") == "FALSE")
97+
#expect(schema.storage.storageValue(forKey: "boolStringTrueFalseUppercase") as String? == "FALSE")
9898
#expect(schema.boolStringTrueFalseUppercase == false)
9999
}
100100

@@ -127,11 +127,11 @@ struct BoolStringPrefsCodingTests {
127127
let schema = TestSchema()
128128

129129
schema.boolStringCustomCaseInsensitive = true
130-
#expect(schema.storage.storageValue<String>(forKey: "boolStringCustomCaseInsensitive") == "Oui")
130+
#expect(schema.storage.storageValue(forKey: "boolStringCustomCaseInsensitive") as String? == "Oui")
131131
#expect(schema.boolStringCustomCaseInsensitive == true)
132132

133133
schema.boolStringCustomCaseInsensitive = false
134-
#expect(schema.storage.storageValue<String>(forKey: "boolStringCustomCaseInsensitive") == "Non")
134+
#expect(schema.storage.storageValue(forKey: "boolStringCustomCaseInsensitive") as String? == "Non")
135135
#expect(schema.boolStringCustomCaseInsensitive == false)
136136

137137
schema.storage.setStorageValue(forKey: "boolStringCustomCaseInsensitive", to: "oui")
@@ -147,11 +147,11 @@ struct BoolStringPrefsCodingTests {
147147
let schema = TestSchema()
148148

149149
schema.boolStringCustomNonCaseInsensitive = true
150-
#expect(schema.storage.storageValue<String>(forKey: "boolStringCustomNonCaseInsensitive") == "Oui")
150+
#expect(schema.storage.storageValue(forKey: "boolStringCustomNonCaseInsensitive") as String? == "Oui")
151151
#expect(schema.boolStringCustomNonCaseInsensitive == true)
152152

153153
schema.boolStringCustomNonCaseInsensitive = false
154-
#expect(schema.storage.storageValue<String>(forKey: "boolStringCustomNonCaseInsensitive") == "Non")
154+
#expect(schema.storage.storageValue(forKey: "boolStringCustomNonCaseInsensitive") as String? == "Non")
155155
#expect(schema.boolStringCustomNonCaseInsensitive == false)
156156

157157
schema.storage.setStorageValue(forKey: "boolStringCustomNonCaseInsensitive", to: "oui")
@@ -169,11 +169,11 @@ struct BoolStringPrefsCodingTests {
169169
let schema = TestSchema()
170170

171171
schema.myTypeBoolStringChained = .yes
172-
#expect(schema.storage.storageValue<String>(forKey: "myTypeBoolStringChained") == "true")
172+
#expect(schema.storage.storageValue(forKey: "myTypeBoolStringChained") as String? == "true")
173173
#expect(schema.myTypeBoolStringChained == .yes)
174174

175175
schema.myTypeBoolStringChained = .no
176-
#expect(schema.storage.storageValue<String>(forKey: "myTypeBoolStringChained") == "false")
176+
#expect(schema.storage.storageValue(forKey: "myTypeBoolStringChained") as String? == "false")
177177
#expect(schema.myTypeBoolStringChained == .no)
178178

179179
schema.storage.setStorageValue(forKey: "myTypeBoolStringChained", to: "foobar")

Tests/PrefsKitCoreTests/PrefsCodable Strategies/CompressedDataPrefsCodingTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct CompressedDataPrefsCodingTests {
4343
let testData = Data([0x01, 0x02, 0x03])
4444

4545
schema.data = testData
46-
#expect(schema.storage.storageValue<Data>(forKey: "data") == Data([0x63, 0x64, 0x62, 0x06, 0x00]))
46+
#expect(schema.storage.storageValue(forKey: "data") as Data? == Data([0x63, 0x64, 0x62, 0x06, 0x00]))
4747
#expect(schema.data == testData)
4848
}
4949

@@ -55,7 +55,7 @@ struct CompressedDataPrefsCodingTests {
5555
let testType = MyType(id: 123, name: "foo")
5656

5757
schema.myTypeChained = testType
58-
let getData: Data = try #require(schema.storage.storageValue<Data>(forKey: "myTypeChained"))
58+
let getData: Data = try #require(schema.storage.storageValue(forKey: "myTypeChained"))
5959
// just check for non-empty content, we won't check actual content since it's not fully deterministic
6060
#expect(getData.count > 10)
6161
#expect(schema.myTypeChained == testType)

Tests/PrefsKitCoreTests/PrefsCodable Strategies/ISO8601StringDatePrefsCodingTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct ISO8601StringDatePrefsCodingTests {
3030
let testDate = Date(timeIntervalSinceReferenceDate: 757_493_476)
3131

3232
schema.date = testDate
33-
#expect(schema.storage.storageValue<String>(forKey: "date") == "2025-01-02T06:51:16Z")
33+
#expect(schema.storage.storageValue(forKey: "date") as String? == "2025-01-02T06:51:16Z")
3434
#expect(schema.date == testDate)
3535
}
3636

Tests/PrefsKitCoreTests/PrefsCodable Strategies/IntegerPrefsCodingTests.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct IntegerPrefsCodingTests {
4141

4242
// can't use UInt.max, would overflow Int. so we'll use Int.max
4343
schema.uInt_As_Int = 9223372036854775807 // Int.max
44-
#expect(schema.storage.storageValue<Int>(forKey: "uInt_As_Int") == 9223372036854775807)
44+
#expect(schema.storage.storageValue(forKey: "uInt_As_Int") as Int? == 9223372036854775807)
4545
#expect(schema.uInt_As_Int == 9223372036854775807)
4646
}
4747

@@ -51,11 +51,11 @@ struct IntegerPrefsCodingTests {
5151
let schema = TestSchema()
5252

5353
schema.int8_As_Int = 127 // Int8.max
54-
#expect(schema.storage.storageValue<Int>(forKey: "int8_As_Int") == 127)
54+
#expect(schema.storage.storageValue(forKey: "int8_As_Int") as Int? == 127)
5555
#expect(schema.int8_As_Int == 127)
5656

5757
schema.int8_As_Int = -128 // Int8.min
58-
#expect(schema.storage.storageValue<Int>(forKey: "int8_As_Int") == -128)
58+
#expect(schema.storage.storageValue(forKey: "int8_As_Int") as Int? == -128)
5959
#expect(schema.int8_As_Int == -128)
6060
}
6161

@@ -65,7 +65,7 @@ struct IntegerPrefsCodingTests {
6565
let schema = TestSchema()
6666

6767
schema.uInt8_As_Int = 255 // UInt8.max
68-
#expect(schema.storage.storageValue<Int>(forKey: "uInt8_As_Int") == 255)
68+
#expect(schema.storage.storageValue(forKey: "uInt8_As_Int") as Int? == 255)
6969
#expect(schema.uInt8_As_Int == 255)
7070
}
7171

@@ -75,11 +75,11 @@ struct IntegerPrefsCodingTests {
7575
let schema = TestSchema()
7676

7777
schema.int16_As_Int = 32767 // Int16.max
78-
#expect(schema.storage.storageValue<Int>(forKey: "int16_As_Int") == 32767)
78+
#expect(schema.storage.storageValue(forKey: "int16_As_Int") as Int? == 32767)
7979
#expect(schema.int16_As_Int == 32767)
8080

8181
schema.int16_As_Int = -32768 // Int16.min
82-
#expect(schema.storage.storageValue<Int>(forKey: "int16_As_Int") == -32768)
82+
#expect(schema.storage.storageValue(forKey: "int16_As_Int") as Int? == -32768)
8383
#expect(schema.int16_As_Int == -32768)
8484
}
8585

@@ -89,7 +89,7 @@ struct IntegerPrefsCodingTests {
8989
let schema = TestSchema()
9090

9191
schema.uInt16_As_Int = 65535 // UInt16.max
92-
#expect(schema.storage.storageValue<Int>(forKey: "uInt16_As_Int") == 65535)
92+
#expect(schema.storage.storageValue(forKey: "uInt16_As_Int") as Int? == 65535)
9393
#expect(schema.uInt16_As_Int == 65535)
9494
}
9595

@@ -99,11 +99,11 @@ struct IntegerPrefsCodingTests {
9999
let schema = TestSchema()
100100

101101
schema.int32_As_Int = 2147483647 // Int32.max
102-
#expect(schema.storage.storageValue<Int>(forKey: "int32_As_Int") == 2147483647)
102+
#expect(schema.storage.storageValue(forKey: "int32_As_Int") as Int? == 2147483647)
103103
#expect(schema.int32_As_Int == 2147483647)
104104

105105
schema.int32_As_Int = -2147483648 // Int32.min
106-
#expect(schema.storage.storageValue<Int>(forKey: "int32_As_Int") == -2147483648)
106+
#expect(schema.storage.storageValue(forKey: "int32_As_Int") as Int? == -2147483648)
107107
#expect(schema.int32_As_Int == -2147483648)
108108
}
109109

@@ -113,7 +113,7 @@ struct IntegerPrefsCodingTests {
113113
let schema = TestSchema()
114114

115115
schema.uInt32_As_Int = 23456
116-
#expect(schema.storage.storageValue<Int>(forKey: "uInt32_As_Int") == 23456)
116+
#expect(schema.storage.storageValue(forKey: "uInt32_As_Int") as Int? == 23456)
117117
#expect(schema.uInt32_As_Int == 23456)
118118
}
119119

@@ -123,11 +123,11 @@ struct IntegerPrefsCodingTests {
123123
let schema = TestSchema()
124124

125125
schema.int64_As_Int = 9223372036854775807 // Int64.max
126-
#expect(schema.storage.storageValue<Int>(forKey: "int64_As_Int") == 9223372036854775807)
126+
#expect(schema.storage.storageValue(forKey: "int64_As_Int") as Int? == 9223372036854775807)
127127
#expect(schema.int64_As_Int == 9223372036854775807)
128128

129129
schema.int64_As_Int = -9223372036854775808 // Int64.min
130-
#expect(schema.storage.storageValue<Int>(forKey: "int64_As_Int") == -9223372036854775808)
130+
#expect(schema.storage.storageValue(forKey: "int64_As_Int") as Int? == -9223372036854775808)
131131
#expect(schema.int64_As_Int == -9223372036854775808)
132132
}
133133

@@ -138,7 +138,7 @@ struct IntegerPrefsCodingTests {
138138

139139
// can't use UInt64.max, would overflow Int. so we'll use Int.max
140140
schema.uInt64_As_Int = 9223372036854775807 // Int.max
141-
#expect(schema.storage.storageValue<Int>(forKey: "uInt64_As_Int") == 9223372036854775807)
141+
#expect(schema.storage.storageValue(forKey: "uInt64_As_Int") as Int? == 9223372036854775807)
142142
#expect(schema.uInt64_As_Int == 9223372036854775807)
143143
}
144144
}

0 commit comments

Comments
 (0)