TestTypeString tests Type.String function
(t *testing.T)
| 12 | |
| 13 | // TestTypeString tests Type.String function |
| 14 | func TestTypeString(t *testing.T) { |
| 15 | type testData struct { |
| 16 | ty Type // Input Type |
| 17 | s string // Expected output string |
| 18 | } |
| 19 | |
| 20 | tests := []testData{ |
| 21 | {TypeInvalid, "Invalid"}, |
| 22 | {TypeVoid, "Void"}, |
| 23 | {TypeBoolean, "Boolean"}, |
| 24 | {TypeString, "String"}, |
| 25 | {TypeDateTime, "DateTime"}, |
| 26 | {TypeResolution, "Resolution"}, |
| 27 | {TypeRange, "Range"}, |
| 28 | {TypeTextWithLang, "TextWithLang"}, |
| 29 | {TypeBinary, "Binary"}, |
| 30 | {TypeCollection, "Collection"}, |
| 31 | {0x1234, "0x1234"}, |
| 32 | } |
| 33 | |
| 34 | for _, test := range tests { |
| 35 | s := test.ty.String() |
| 36 | if s != test.s { |
| 37 | t.Errorf("testing Type.String:\n"+ |
| 38 | "input: %d\n"+ |
| 39 | "expected: %s\n"+ |
| 40 | "present: %s\n", |
| 41 | int(test.ty), test.s, s, |
| 42 | ) |
| 43 | } |
| 44 | } |
| 45 | } |