Debian Codegraph @

schema/unparse_test.go

raw symbols SCIP
1 package schema
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7 )
8
9 func TestUnparseValue(t *testing.T) {
10 var (
11 err error
12 schema string
13
14 u8 uint8
15 u16 uint16
16 u32 uint32
17 u64 uint64
18 u uint
19 i8 int8
20 i16 int16
21 i32 int32
22 i64 int64
23 i int
24 f32 float32
25 f64 float64
26 b bool
27 str string
28 )
29
30 schema, err = SchemaFor(&u8)
31 assert.Nil(t, err, "Expected SchemaFor to return without error")
32 assert.Equal(t, schema, "u8", "Expected SchemaFor to return u8")
33
34 schema, err = SchemaFor(&u16)
35 assert.Nil(t, err, "Expected SchemaFor to return without error")
36 assert.Equal(t, schema, "u16", "Expected SchemaFor to return u16")
37
38 schema, err = SchemaFor(&u32)
39 assert.Nil(t, err, "Expected SchemaFor to return without error")
40 assert.Equal(t, schema, "u32", "Expected SchemaFor to return u32")
41
42 schema, err = SchemaFor(&u64)
43 assert.Nil(t, err, "Expected SchemaFor to return without error")
44 assert.Equal(t, schema, "u64", "Expected SchemaFor to return u64")
45
46 schema, err = SchemaFor(&u)
47 assert.Nil(t, err, "Expected SchemaFor to return without error")
48 assert.Equal(t, schema, "uint", "Expected SchemaFor to return u32")
49
50 schema, err = SchemaFor(&i8)
51 assert.Nil(t, err, "Expected SchemaFor to return without error")
52 assert.Equal(t, schema, "i8", "Expected SchemaFor to return i8")
53
54 schema, err = SchemaFor(&i16)
55 assert.Nil(t, err, "Expected SchemaFor to return without error")
56 assert.Equal(t, schema, "i16", "Expected SchemaFor to return i16")
57
58 schema, err = SchemaFor(&i32)
59 assert.Nil(t, err, "Expected SchemaFor to return without error")
60 assert.Equal(t, schema, "i32", "Expected SchemaFor to return i32")
61
62 schema, err = SchemaFor(&i64)
63 assert.Nil(t, err, "Expected SchemaFor to return without error")
64 assert.Equal(t, schema, "i64", "Expected SchemaFor to return i64")
65
66 schema, err = SchemaFor(&i)
67 assert.Nil(t, err, "Expected SchemaFor to return without error")
68 assert.Equal(t, schema, "int", "Expected SchemaFor to return i32")
69
70 schema, err = SchemaFor(&f32)
71 assert.Nil(t, err, "Expected SchemaFor to return without error")
72 assert.Equal(t, schema, "f32", "Expected SchemaFor to return f32")
73
74 schema, err = SchemaFor(&f64)
75 assert.Nil(t, err, "Expected SchemaFor to return without error")
76 assert.Equal(t, schema, "f64", "Expected SchemaFor to return f64")
77
78 schema, err = SchemaFor(&b)
79 assert.Nil(t, err, "Expected SchemaFor to return without error")
80 assert.Equal(t, schema, "bool", "Expected SchemaFor to return bool")
81
82 schema, err = SchemaFor(&str)
83 assert.Nil(t, err, "Expected SchemaFor to return without error")
84 assert.Equal(t, schema, "string", "Expected SchemaFor to return string")
85 }
86
87 func TestUnparseOptional(t *testing.T) {
88 var val *string
89 schema, err := SchemaFor(&val)
90 assert.Nil(t, err, "Expected SchemaFor to return without error")
91 assert.Equal(t, schema, "optional<string>",
92 "Expected SchemaFor to return optional<string>")
93 }