-
Notifications
You must be signed in to change notification settings - Fork 1
/
convertAll_test.go
102 lines (81 loc) · 1.66 KB
/
convertAll_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package zouyu
import (
"fmt"
"io/ioutil"
"log"
"testing"
)
func TestSearchAndReplace(t *testing.T) {
fmt.Println("Happy Testing!")
file1 := input1
fnOut1 := ConvertFile(file1)
if fnOut1 != output1 {
t.Fail()
}
}
// writeTwoOutputsForComparison is
// a small utility for writing to two different
// files so that you can use the 'diff' command on
// the two files and see what the difference is.
// It should be helpful for figuring out why your tests
// aren't passing.
func writeTwoOutputsForComparison(output1, output2 string) {
// Let's write to a file to see the diff.
bytes := []byte(output1)
err := ioutil.WriteFile("input.txt", bytes, 0644)
if err != nil {
log.Fatal(err)
}
bytes = []byte(output2)
err = ioutil.WriteFile("output.txt", bytes, 0644)
if err != nil {
log.Fatal(err)
}
}
var input1 = `// +build ignore
包裹 主要
进口 (
"fmt"
"time"
)
函数 主要() {
循环 i := 0; i < 10; i++ {
fmt.Printf("第%v个\n", i+1)
}
fmt.Println("走语考试开始了")
项目 := 初始化([]整数, 3)
循环 _, v := 范围 项目 {
fmt.Println(v)
}
走 函数() {
fmt.Println("时间过得很慢")
}()
time.Sleep(2 * time.Second)
走 函数() {
fmt.Println("时间过得很慢")
}()
time.Sleep(2 * time.Second)
}`
var output1 = `package main
import (
"fmt"
"time"
)
func main() {
for i := 0; i < 10; i++ {
fmt.Printf("第%v个\n", i+1)
}
fmt.Println("走语考试开始了")
项目 := make([]int, 3)
for _, v := range 项目 {
fmt.Println(v)
}
go func() {
fmt.Println("时间过得很慢")
}()
time.Sleep(2 * time.Second)
go func() {
fmt.Println("时间过得很慢")
}()
time.Sleep(2 * time.Second)
}`