File tree 1 file changed +18
-4
lines changed
1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 1
1
package gophpserialize
2
2
3
3
import (
4
- "testing"
4
+ "testing"
5
5
)
6
6
7
+ func TestUnmarshalString (t * testing.T ) {
8
+ data := `a:8:{s:4:"type";s:12:"package-coin";s:6:"useBag";i:0;s:3:"gid";s:5:"20000";s:3:"num";i:1;s:3:"rid";i:105698894;s:4:"from";s:9:"800005631";s:2:"to";s:9:"800240177";s:6:"_use_g";i:10;}`
9
+
10
+ obj := Unmarshal ([]byte (data )).(map [string ]interface {})
11
+
12
+ if obj ["type" ] != "package-coin" {
13
+ t .Error ("Unmarshal failed" )
14
+ }
15
+
16
+ if obj ["rid" ] != 105698894 {
17
+ t .Error ("Unmarshal failed" )
18
+ }
19
+ }
20
+
7
21
func TestUnmarshal (t * testing.T ) {
8
22
data := `a:3:{s:5:"apple";i:1;s:6:"orange";i:2;s:5:"grape";i:3;}`
9
23
@@ -21,9 +35,9 @@ func TestUnmarshal(t *testing.T) {
21
35
22
36
data = `a:1:{s:7:"catalog";a:3:{i:2;a:4:{s:5:"width";s:3:"236";s:6:"height";s:3:"345";s:7:"quality";s:2:"90";s:13:"image_formats";s:3:"jpg";}i:1;a:4:{s:5:"width";s:3:"160";s:6:"height";s:3:"160";s:7:"quality";s:2:"80";s:13:"image_formats";s:3:"jpg";}i:3;a:4:{s:5:"width";s:3:"160";s:6:"height";s:3:"160";s:7:"quality";s:2:"80";s:13:"image_formats";s:3:"jpg";}}`
23
37
obj = Unmarshal ([]byte (data )).(map [string ]interface {})
24
- if _ , hasV := obj ["catalog" ].(map [string ]interface {})["0" ]; hasV == true {
25
- t .Error ("Unmarshal failed" )
26
- }
38
+ if _ , hasV := obj ["catalog" ].(map [string ]interface {})["0" ]; hasV == true {
39
+ t .Error ("Unmarshal failed" )
40
+ }
27
41
}
28
42
29
43
func TestPhpToJson (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments