diff options
Diffstat (limited to 'skate/schema_test.go')
-rw-r--r-- | skate/schema_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/skate/schema_test.go b/skate/schema_test.go index 59b1f58..3e783df 100644 --- a/skate/schema_test.go +++ b/skate/schema_test.go @@ -364,6 +364,37 @@ func TestReleaseToUnstructured(t *testing.T) { } } +func TestCSLDateString(t *testing.T) { + var cases = []struct { + date CSLDate + s string + }{ + {CSLDate{}, ""}, + {CSLDate{Raw: "2012"}, "2012"}, + {CSLDate{Raw: "about 2012"}, "about 2012"}, + {CSLDate{Raw: "", Parts: nil}, ""}, + {CSLDate{Raw: "", Parts: [][]int{}}, ""}, + {CSLDate{Raw: "", Parts: [][]int{ + []int{2001}, + }}, "2001"}, + {CSLDate{Raw: "", Parts: [][]int{ + []int{2001, 1}, + }}, "2001-01"}, + {CSLDate{Raw: "", Parts: [][]int{ + []int{2001, 1, 1}, + }}, "2001-01-01"}, + {CSLDate{Raw: "", Parts: [][]int{ + []int{2001, 1, 12}, + }}, "2001-01-12"}, + } + for i, c := range cases { + result := c.date.String() + if result != c.s { + t.Fatalf("[%d] got %v, want %v", i, result, c.s) + } + } +} + func BenchmarkParseIsbn(b *testing.B) { for n := 0; n < b.N; n++ { ParseIsbn("House Pvt. Limited., (2006), ISBN 9788183561426. Date accessed: August 2015.") |