@@ -5,6 +5,15 @@ import Foundation
55import UIKit
66#endif
77
8+ struct CodableObject : Codable , Identifiable {
9+ let id : UUID
10+ var text : String
11+
12+ enum CodingKeys : String , CodingKey {
13+ case id, text = " t_ext "
14+ }
15+ }
16+
817struct Params {
918 let lookup : Lookup
1019 init ( _ lookup: Lookup ) {
@@ -498,11 +507,11 @@ struct LookupTests {
498507 #expect( lookup. toID. string == " 10086 " )
499508 #expect( lookup. toID. int == 10086 )
500509
501- #expect( lookup. markup. keyboards . 0 . 0 . text. string == " Hang up " )
502- #expect( lookup. markup. keyboards . 0 . 0 . callbackData . string == " /hang-up " )
510+ #expect( lookup. markup. inline_keyboard . 0 . 0 . text. string == " Hang up " )
511+ #expect( lookup. markup. inline_keyboard . 0 . 0 . callback_data . string == " /hang-up " )
503512
504- #expect( lookup. markup. keyboards . 1 . 0 . text. string == " Recording " )
505- #expect( lookup. markup. keyboards . 1 . 0 . callbackData . string == " /recording " )
513+ #expect( lookup. markup. inline_keyboard . 1 . 0 . text. string == " Recording " )
514+ #expect( lookup. markup. inline_keyboard . 1 . 0 . callback_data . string == " /recording " )
506515 }
507516
508517 @Test ( " Test Unwrap " )
@@ -528,6 +537,16 @@ struct LookupTests {
528537 #expect( lookup. ids. count == 1 )
529538 }
530539
540+ // Codable 需要获取 CodingKeys 的结果,否则服务端会出问题。。。
541+ @Test ( " Test Codable Object " )
542+ func testCodableObject( ) throws {
543+
544+ let lookup = Lookup ( CodableObject ( id: UUID ( ) , text: " Hello, world! " ) )
545+ print ( lookup. description)
546+ // t_ext is Codable `CodingKey`
547+ #expect( lookup. t_ext. string == " Hello, world! " )
548+ }
549+
531550 #if os(iOS)
532551 @Test ( " Test UIView " )
533552 func testUIView( ) throws {
0 commit comments