-
Notifications
You must be signed in to change notification settings - Fork 136
/
gendoc_test.go
98 lines (86 loc) · 1.92 KB
/
gendoc_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
package main
import (
"strings"
"testing"
)
func TestSformatHCL(t *testing.T) {
hcl := `
'hcl
data "tencentcloud_as_scaling_configs" "as_configs" {
configuration_id="asc-oqio4yyj"
result_output_file="my_test_path"
}
'
`
hclExp := `'hcl
data "tencentcloud_as_scaling_configs" "as_configs" {
configuration_id = "asc-oqio4yyj"
result_output_file = "my_test_path"
}
'`
hcl = strings.Replace(hcl, "'", "```", -1)
hclExp = strings.Replace(hclExp, "'", "```", -1)
hcl = formatHCL(hcl)
if hcl != hclExp {
t.Error("format hcl failed")
}
}
func TestMformatHCL(t *testing.T) {
hcl := `
Private Bucket
'hcl
resource "tencentcloud_cos_bucket" "mycos" {
bucket = "mycos-1258798060"
acl = "private"
}
'
Static Website
'hcl
resource "tencentcloud_cos_bucket" "mycos" {
bucket = "mycos-1258798060"
website = {
index_document = "index.html"
error_document = "error.html"
}
}
'
`
hclExp := `Private Bucket
'hcl
resource "tencentcloud_cos_bucket" "mycos" {
bucket = "mycos-1258798060"
acl = "private"
}
'
Static Website
'hcl
resource "tencentcloud_cos_bucket" "mycos" {
bucket = "mycos-1258798060"
website = {
index_document = "index.html"
error_document = "error.html"
}
}
'`
hcl = strings.Replace(hcl, "'", "```", -1)
hclExp = strings.Replace(hclExp, "'", "```", -1)
hcl = formatHCL(hcl)
if hcl != hclExp {
t.Error("format hcl failed")
}
}
func TestContainsBigSymbol(t *testing.T) {
cases := "中国人繁體字abcABC~!@#¥%…&()—+{}|:“”《》?1234567890-=【】\;‘’,。、 "
for _, c := range cases {
if containsBigSymbol(string(c)) == "" {
t.Log(c)
t.Errorf("Expected %s to be Chinese symbol", string(c))
}
}
cases = "abcABC~!@#$%^&*()_+{}|:\"<>?`1234567890-=[]\\;',./ \t\r\n"
for _, c := range cases {
if containsBigSymbol(string(c)) != "" {
t.Errorf("Expected %s not to be Chinese symbol", string(c))
}
}
}