aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--skate/schema_test.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/skate/schema_test.go b/skate/schema_test.go
index c1cec35..0f84703 100644
--- a/skate/schema_test.go
+++ b/skate/schema_test.go
@@ -146,3 +146,61 @@ func prettyStructDiff(s, t interface{}) string {
_, d := jsondiff.Compare(b, c, &opts)
return d
}
+
+func TestParseIsbn(t *testing.T) {
+ var cases = []struct {
+ s string
+ result []string
+ }{
+ {s: "", result: nil},
+ {s: "0000000000000000000000", result: nil},
+ {s: "978953510472X", result: nil},
+ {s: "9789535104728 9789535104728 9789535104728", result: []string{"9789535104728"}},
+ {
+ s: "Continuous, .. Dr. Marina Pana (Ed.), ISBN: 978-953-51-0472-8, InTech, Available from",
+ result: []string{"9789535104728"},
+ },
+ {
+ s: "(IGN). Madrid. M. de Fomento ISBN 84-498-0665-8",
+ result: []string{"9788449806650"},
+ },
+ {
+ s: "House Pvt. Limited., (2006), ISBN 9788183561426. Date accessed: August 2015.",
+ result: []string{"9788183561426"},
+ },
+ {
+ s: "Electrolytes. 2003. ISBN 0-9726720-0-1. Pages 341, 357.",
+ result: []string{"9780972672009"},
+ },
+ {
+ s: "£25.00. ISBN 0 631 15254 7. First published in Italian in 1985.",
+ result: []string{"9780631152545"},
+ },
+ {
+ s: "Kluwer Academic Inc., 1996. ISBN O- 7923-9777-0.",
+ result: []string{"9780792397779"},
+ },
+ {
+ s: "Fisheries and Aquaculture, Rome 2012; ISBN: 978-92-5- 107225-7.",
+ result: []string{"9789251072257"},
+ },
+ {
+ s: " Praha; iSBn 80-247- 1046-3.",
+ result: []string{"9788024710464"},
+ },
+ {
+ s: "Avialable at: http://www.urn.fi/urn:isbn:9514257693 (accessed: 3.07.2017).",
+ result: []string{"9789514257698"},
+ },
+ {
+ s: "Colegio de Arquitectos de Málaga, 1987, ISBN: 8439899939, 9788439899938.",
+ result: []string{"9788439899938"},
+ },
+ }
+ for _, c := range cases {
+ r := parseIsbn(c.s)
+ if !reflect.DeepEqual(r, c.result) {
+ t.Fatalf("got %v, want %v", r, c.result)
+ }
+ }
+}