1
2
3
4
5
6
7 package bsontype
8
9 import "testing"
10
11 func TestType(t *testing.T) {
12 testCases := []struct {
13 name string
14 t Type
15 want string
16 }{
17 {"double", Double, "double"},
18 {"string", String, "string"},
19 {"embedded document", EmbeddedDocument, "embedded document"},
20 {"array", Array, "array"},
21 {"binary", Binary, "binary"},
22 {"undefined", Undefined, "undefined"},
23 {"objectID", ObjectID, "objectID"},
24 {"boolean", Boolean, "boolean"},
25 {"UTC datetime", DateTime, "UTC datetime"},
26 {"null", Null, "null"},
27 {"regex", Regex, "regex"},
28 {"dbPointer", DBPointer, "dbPointer"},
29 {"javascript", JavaScript, "javascript"},
30 {"symbol", Symbol, "symbol"},
31 {"code with scope", CodeWithScope, "code with scope"},
32 {"32-bit integer", Int32, "32-bit integer"},
33 {"timestamp", Timestamp, "timestamp"},
34 {"64-bit integer", Int64, "64-bit integer"},
35 {"128-bit decimal", Decimal128, "128-bit decimal"},
36 {"min key", MinKey, "min key"},
37 {"max key", MaxKey, "max key"},
38 {"invalid", (0), "invalid"},
39 }
40
41 for _, tc := range testCases {
42 t.Run(tc.name, func(t *testing.T) {
43 got := tc.t.String()
44 if got != tc.want {
45 t.Errorf("String outputs do not match. got %s; want %s", got, tc.want)
46 }
47 })
48 }
49 }
50
View as plain text