-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
72 lines (64 loc) · 1.43 KB
/
main_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2014 The presenti Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"bytes"
"fmt"
"os"
"os/exec"
"path"
"strings"
"testing"
)
var gopath = os.Getenv("GOPATH")
var testfilepath = "src/github.com/dupoxy/presenti/test"
var dotests = []struct {
in string
out string
}{
{"test.go", "test.article"},
}
func TestDo(t *testing.T) {
gopathlist := strings.Split(gopath, ":")
gopath = gopathlist[0]
for _, tt := range dotests {
inpath := path.Join(gopath, testfilepath, tt.in)
outpath := path.Join(gopath, testfilepath, tt.out)
b, err := exec.Command("presenti", inpath).CombinedOutput()
if err != nil {
fmt.Println(err)
}
_, d := readInput(outpath)
ok := bytes.Equal(b, d)
if !ok {
t.Errorf("presenti %q =>\n%s\nWant:\n%s", inpath, b, d)
}
}
}
func TestNewFilteredNote_Bad(t *testing.T) {
s := `
/* I m just /* bad
*/
`
_, err := newFilteredNote(s)
if err == nil {
t.Errorf("newFilteredNote %q => err == nil Want: err != nil", s)
}
if err != nil {
t.Logf("newFilteredNote %q => err != nil Want: err != nil", s)
}
}
func TestNewFilteredNote_Bad2(t *testing.T) {
s := `
/* I m just */ bad
*/
`
_, err := newFilteredNote(s)
if err == nil {
t.Errorf("newFilteredNote %q => err == nil Want: err != nil", s)
}
if err != nil {
t.Logf("newFilteredNote %q => err != nil Want: err != nil", s)
}
}