@@ -116,17 +116,20 @@ final class GenerativeModelTests: XCTestCase {
116
116
XCTAssertEqual ( citationSource1. uri, " https://www.example.com/some-citation-1 " )
117
117
XCTAssertEqual ( citationSource1. startIndex, 0 )
118
118
XCTAssertEqual ( citationSource1. endIndex, 128 )
119
+ XCTAssertNil ( citationSource1. title)
119
120
XCTAssertNil ( citationSource1. license)
120
121
let citationSource2 = try XCTUnwrap ( citationMetadata. citationSources [ 1 ] )
121
- XCTAssertEqual ( citationSource2. uri , " https://www.example.com/ some-citation-2" )
122
+ XCTAssertEqual ( citationSource2. title , " some-citation-2 " )
122
123
XCTAssertEqual ( citationSource2. startIndex, 130 )
123
124
XCTAssertEqual ( citationSource2. endIndex, 265 )
125
+ XCTAssertNil ( citationSource2. uri)
124
126
XCTAssertNil ( citationSource2. license)
125
127
let citationSource3 = try XCTUnwrap ( citationMetadata. citationSources [ 2 ] )
126
128
XCTAssertEqual ( citationSource3. uri, " https://www.example.com/some-citation-3 " )
127
129
XCTAssertEqual ( citationSource3. startIndex, 272 )
128
130
XCTAssertEqual ( citationSource3. endIndex, 431 )
129
131
XCTAssertEqual ( citationSource3. license, " mit " )
132
+ XCTAssertNil ( citationSource3. title)
130
133
}
131
134
132
135
func testGenerateContent_success_quoteReply( ) async throws {
@@ -951,13 +954,25 @@ final class GenerativeModelTests: XCTestCase {
951
954
XCTAssertEqual ( lastCandidate. finishReason, . stop)
952
955
XCTAssertEqual ( citations. count, 6 )
953
956
XCTAssertTrue ( citations
954
- . contains ( where: {
955
- $0. startIndex == 574 && $0. endIndex == 705 && !$0. uri. isEmpty && $0. license == " "
956
- } ) )
957
+ . contains {
958
+ $0. startIndex == 0 && $0. endIndex == 128
959
+ && $0. uri == " https://www.example.com/some-citation-1 " && $0. title == nil
960
+ && $0. license == nil
961
+ } )
957
962
XCTAssertTrue ( citations
958
- . contains ( where: {
959
- $0. startIndex == 899 && $0. endIndex == 1026 && !$0. uri. isEmpty && $0. license == " "
960
- } ) )
963
+ . contains {
964
+ $0. startIndex == 130 && $0. endIndex == 265 && $0. uri == nil
965
+ && $0. title == " some-citation-2 " && $0. license == nil
966
+ } )
967
+ XCTAssertTrue ( citations
968
+ . contains {
969
+ $0. startIndex == 272 && $0. endIndex == 431
970
+ && $0. uri == " https://www.example.com/some-citation-3 " && $0. title == nil
971
+ && $0. license == " mit "
972
+ } )
973
+ XCTAssertFalse ( citations. contains { $0. uri? . isEmpty ?? false } )
974
+ XCTAssertFalse ( citations. contains { $0. title? . isEmpty ?? false } )
975
+ XCTAssertFalse ( citations. contains { $0. license? . isEmpty ?? false } )
961
976
}
962
977
963
978
func testGenerateContentStream_appCheck_validToken( ) async throws {
@@ -1283,9 +1298,9 @@ final class GenerativeModelTests: XCTestCase {
1283
1298
) ) {
1284
1299
// Skip tests using MockURLProtocol on watchOS; unsupported in watchOS 2 and later, see
1285
1300
// https://developer.apple.com/documentation/foundation/urlprotocol for details.
1286
- guard #unavailable ( watchOS 2 ) else {
1301
+ #if os (watchOS)
1287
1302
throw XCTSkip ( " Custom URL protocols are unsupported in watchOS 2 and later. " )
1288
- }
1303
+ #endif // os(watchOS)
1289
1304
return { request in
1290
1305
// This is *not* an HTTPURLResponse
1291
1306
let response = URLResponse (
@@ -1309,9 +1324,9 @@ final class GenerativeModelTests: XCTestCase {
1309
1324
) ) {
1310
1325
// Skip tests using MockURLProtocol on watchOS; unsupported in watchOS 2 and later, see
1311
1326
// https://developer.apple.com/documentation/foundation/urlprotocol for details.
1312
- guard #unavailable ( watchOS 2 ) else {
1327
+ #if os (watchOS)
1313
1328
throw XCTSkip ( " Custom URL protocols are unsupported in watchOS 2 and later. " )
1314
- }
1329
+ #endif // os(watchOS)
1315
1330
let fileURL = try XCTUnwrap ( Bundle . module. url ( forResource: name, withExtension: ext) )
1316
1331
return { request in
1317
1332
let requestURL = try XCTUnwrap ( request. url)
0 commit comments