@@ -2288,14 +2288,44 @@ func TestCustomProps(t *testing.T) {
2288
2288
assert .True (t , ret .Get ("error" ).IsNull ())
2289
2289
}
2290
2290
2291
- ret := f .(js.Value ).Call ("SetCustomProps" )
2291
+ ret := f .(js.Value ).Call ("GetCustomProps" )
2292
+ assert .Equal (t , ret .Get ("props" ).Length (), 4 )
2293
+ assert .Equal (t , ret .Get ("props" ).Index (0 ).Get ("Value" ).String (), "text" )
2294
+ assert .True (t , ret .Get ("props" ).Index (1 ).Get ("Value" ).Bool ())
2295
+ assert .False (t , ret .Get ("props" ).Index (2 ).Get ("Value" ).Bool ())
2296
+ assert .Equal (t , ret .Get ("props" ).Index (3 ).Get ("Value" ).Float (), - 123.456 )
2297
+
2298
+ ret = f .(js.Value ).Call ("SetCustomProps" )
2292
2299
assert .EqualError (t , errArgNum , ret .Get ("error" ).String ())
2293
2300
2294
2301
ret = f .(js.Value ).Call ("SetCustomProps" , js .ValueOf (1 ))
2295
2302
assert .EqualError (t , errArgType , ret .Get ("error" ).String ())
2296
2303
2297
2304
ret = f .(js.Value ).Call ("SetCustomProps" , js .ValueOf (map [string ]interface {}{"Name" : 1 }))
2298
2305
assert .EqualError (t , errArgType , ret .Get ("error" ).String ())
2306
+
2307
+ ret = f .(js.Value ).Call ("GetCustomProps" , js .ValueOf (1 ))
2308
+ assert .EqualError (t , errArgNum , ret .Get ("error" ).String ())
2309
+
2310
+ // Test get custom property with unsupported charset
2311
+ wb := excelize .NewFile ()
2312
+ wb .Sheet .Delete ("docProps/custom.xml" )
2313
+ wb .Pkg .Store ("docProps/custom.xml" , MacintoshCyrillicCharset )
2314
+ buf , err := wb .WriteToBuffer ()
2315
+ assert .NoError (t , err )
2316
+
2317
+ uint8Array := js .Global ().Get ("Uint8Array" ).New (js .ValueOf (buf .Len ()))
2318
+ for k , v := range buf .Bytes () {
2319
+ uint8Array .SetIndex (k , v )
2320
+ }
2321
+ f = OpenReader (js.Value {}, []js.Value {uint8Array })
2322
+ assert .True (t , f .(js.Value ).Get ("error" ).IsNull ())
2323
+ ret = f .(js.Value ).Call ("GetCustomProps" )
2324
+ assert .Equal (t , ret .Get ("error" ).String (), "XML syntax error on line 1: invalid UTF-8" )
2325
+
2326
+ // Test set custom property with unsupported charset
2327
+ ret = f .(js.Value ).Call ("SetCustomProps" , js .ValueOf (map [string ]interface {}{"Name" : "Text Prop" , "Value" : "text" }))
2328
+ assert .Equal (t , ret .Get ("error" ).String (), "XML syntax error on line 1: invalid UTF-8" )
2299
2329
}
2300
2330
2301
2331
func TestSetDefaultFont (t * testing.T ) {
0 commit comments