From 59f87fbcbcc4d6c5ac165d6053c1a3734f48e810 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 22 Nov 2022 16:14:25 +0000 Subject: rescribe: add gbook fuzzer test and fix some bugs it found! --- cmd/rescribe/gbook_test.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'cmd/rescribe/gbook_test.go') diff --git a/cmd/rescribe/gbook_test.go b/cmd/rescribe/gbook_test.go index 56b4b40..f7df595 100644 --- a/cmd/rescribe/gbook_test.go +++ b/cmd/rescribe/gbook_test.go @@ -8,7 +8,7 @@ import ( "testing" ) -func Test_getBookIdFromUrl(t *testing.T) { +func TestGetBookIdFromUrl(t *testing.T) { cases := []struct { url string id string @@ -29,3 +29,18 @@ func Test_getBookIdFromUrl(t *testing.T) { }) } } + +func FuzzGetBookIdFromUrl(f *testing.F) { + cases := []string { + "https://books.google.it/books?id=QjQepCuN8JYC", + "https://www.google.it/books/edition/_/VJbr-Oe2au0C", + } + + for _, c := range cases { + f.Add(c) + } + + f.Fuzz(func(t *testing.T, url string) { + getBookIdFromUrl(url) + }) +} -- cgit v1.2.1-24-ge1ad