aboutsummaryrefslogtreecommitdiff
path: root/main_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/main_test.go b/main_test.go
index 73dc0c8..2d520cb 100644
--- a/main_test.go
+++ b/main_test.go
@@ -26,6 +26,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "regexp"
"strings"
"sync"
"testing"
@@ -301,3 +302,41 @@ func TestParseDate(t *testing.T) {
}
}
}
+
+func TestParseErrors(t *testing.T) {
+ type testval struct {
+ src []byte
+ re *regexp.Regexp
+ n int
+ err error
+ }
+
+ var tests = []testval{
+ {
+ []byte("<h2>Аэростат</h2>"),
+ programNameRe,
+ 1,
+ nil,
+ }, {
+ []byte("<h2>Аэростат</h2><h2>foo</h2>"),
+ programNameRe,
+ 1,
+ nil,
+ }, {
+ []byte{},
+ programNameRe,
+ 1,
+ errCantParse,
+ },
+ }
+
+ for _, test := range tests {
+ res, got := parse(test.src, test.re, test.n)
+ if test.err != got {
+ t.Error("for", test.src, test.re, test.n, "\nwant:", test.err, "got:", got)
+ }
+ if test.n != len(res) {
+ t.Error("for", test.src, test.re, test.n, "\nwant length:", test.n, "got:", len(res))
+ }
+ }
+}