-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsources_test.go
49 lines (37 loc) · 1.04 KB
/
sources_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"fmt"
"testing"
)
func TestSourceJsonFiles(t *testing.T) {
sources := GetSources()
fmt.Printf("Testing %v source files\n", len(sources))
for _, sourceFile := range sources {
source, err := GetSourceContent(sourceFile)
if err != nil {
t.Logf("Source file %v contains invalid Json", sourceFile)
t.FailNow()
}
if source.Source == "" {
t.Errorf("Source field inside the %v file is empty", sourceFile)
}
if len(source.Paragraphs) == 0 {
t.Errorf("Source file %v contains no paragraphs", sourceFile)
}
for index, paragraph := range source.Paragraphs {
if paragraph == "" {
t.Errorf("Paragraph %v the %v file is empty", index, sourceFile)
}
}
}
}
func TestNumLinesFunction(t *testing.T) {
source := GetNumLines(5, false)
if len(source.Paragraphs) != 5 {
t.Errorf("%v paragraphs returned, exptected %v", len(source.Paragraphs), 5)
}
source2 := GetNumLines(50, false)
if len(source2.Paragraphs) != 50 {
t.Errorf("%v paragraphs returned, exptected %v", len(source2.Paragraphs), 50)
}
}