summaryrefslogtreecommitdiff
path: root/src/lib/json/struct_test.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-01-16 10:14:38 -0800
committerRuss Cox <rsc@golang.org>2009-01-16 10:14:38 -0800
commit27026881edb14bf3e449b5ddc27767ce15fc11cb (patch)
treec3556dc8c914a5be09d0efc7d357369a76867b0d /src/lib/json/struct_test.go
parent07b29e74deba1289f518d5f49147c966b119d1f3 (diff)
downloadgolang-27026881edb14bf3e449b5ddc27767ce15fc11cb.tar.gz
casify json
R=r DELTA=163 (0 added, 0 deleted, 163 changed) OCL=22910 CL=22939
Diffstat (limited to 'src/lib/json/struct_test.go')
-rw-r--r--src/lib/json/struct_test.go56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/lib/json/struct_test.go b/src/lib/json/struct_test.go
index 9f8615a36..d0c15c297 100644
--- a/src/lib/json/struct_test.go
+++ b/src/lib/json/struct_test.go
@@ -9,7 +9,7 @@ import (
"testing";
)
-type MyStruct struct {
+type _MyStruct struct {
t bool;
f bool;
s string;
@@ -27,10 +27,10 @@ type MyStruct struct {
fl32 float32;
fl64 float64;
a *[]string; // TODO(rsc): Should be able to use []string.
- my *MyStruct;
+ my *_MyStruct;
};
-const Encoded =
+const _Encoded =
`{"t":true,"f":false,"s":"abc","i8":1,"i16":2,"i32":3,"i64":4,`
` "u8":5,"u16":6,"u32":7,"u64":8,`
` "i":-9,"u":10,"bogusfield":"should be ignored",`
@@ -38,7 +38,7 @@ const Encoded =
` "a":["x","y","z"],"my":{"s":"subguy"}}`;
-func Check(t *testing.T, ok bool, name string, v interface{}) {
+func _Check(t *testing.T, ok bool, name string, v interface{}) {
if !ok {
t.Errorf("%s = %v (BAD)", name, v);
} else {
@@ -47,36 +47,36 @@ func Check(t *testing.T, ok bool, name string, v interface{}) {
}
export func TestUnmarshal(t *testing.T) {
- var m MyStruct;
+ var m _MyStruct;
m.f = true;
- ok, errtok := Unmarshal(Encoded, &m);
+ ok, errtok := Unmarshal(_Encoded, &m);
if !ok {
t.Fatalf("Unmarshal failed near %s", errtok);
}
- Check(t, m.t==true, "t", m.t);
- Check(t, m.f==false, "f", m.f);
- Check(t, m.s=="abc", "s", m.s);
- Check(t, m.i8==1, "i8", m.i8);
- Check(t, m.i16==2, "i16", m.i16);
- Check(t, m.i32==3, "i32", m.i32);
- Check(t, m.i64==4, "i64", m.i64);
- Check(t, m.u8==5, "u8", m.u8);
- Check(t, m.u16==6, "u16", m.u16);
- Check(t, m.u32==7, "u32", m.u32);
- Check(t, m.u64==8, "u64", m.u64);
- Check(t, m.i==-9, "i", m.i);
- Check(t, m.u==10, "u", m.u);
- Check(t, m.fl==11.5, "fl", m.fl);
- Check(t, m.fl32==12.25, "fl32", m.fl32);
- Check(t, m.fl64==13.75, "fl64", m.fl64);
- Check(t, m.a!=nil, "a", m.a);
+ _Check(t, m.t==true, "t", m.t);
+ _Check(t, m.f==false, "f", m.f);
+ _Check(t, m.s=="abc", "s", m.s);
+ _Check(t, m.i8==1, "i8", m.i8);
+ _Check(t, m.i16==2, "i16", m.i16);
+ _Check(t, m.i32==3, "i32", m.i32);
+ _Check(t, m.i64==4, "i64", m.i64);
+ _Check(t, m.u8==5, "u8", m.u8);
+ _Check(t, m.u16==6, "u16", m.u16);
+ _Check(t, m.u32==7, "u32", m.u32);
+ _Check(t, m.u64==8, "u64", m.u64);
+ _Check(t, m.i==-9, "i", m.i);
+ _Check(t, m.u==10, "u", m.u);
+ _Check(t, m.fl==11.5, "fl", m.fl);
+ _Check(t, m.fl32==12.25, "fl32", m.fl32);
+ _Check(t, m.fl64==13.75, "fl64", m.fl64);
+ _Check(t, m.a!=nil, "a", m.a);
if m.a != nil {
- Check(t, m.a[0]=="x", "a[0]", m.a[0]);
- Check(t, m.a[1]=="y", "a[1]", m.a[1]);
- Check(t, m.a[2]=="z", "a[2]", m.a[2]);
+ _Check(t, m.a[0]=="x", "a[0]", m.a[0]);
+ _Check(t, m.a[1]=="y", "a[1]", m.a[1]);
+ _Check(t, m.a[2]=="z", "a[2]", m.a[2]);
}
- Check(t, m.my!=nil, "my", m.my);
+ _Check(t, m.my!=nil, "my", m.my);
if m.my != nil {
- Check(t, m.my.s=="subguy", "my.s", m.my.s);
+ _Check(t, m.my.s=="subguy", "my.s", m.my.s);
}
}