-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpreprocess_test.go
More file actions
65 lines (53 loc) · 1.11 KB
/
preprocess_test.go
File metadata and controls
65 lines (53 loc) · 1.11 KB
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
package sqlcode
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vippsas/sqlcode/sqlparser"
)
func TestSchemaSuffixFromHash(t *testing.T) {
t.Run("returns a unique hash", func(t *testing.T) {
doc := sqlparser.Document{
Declares: []sqlparser.Declare{},
}
value := SchemaSuffixFromHash(doc)
require.Equal(t, value, SchemaSuffixFromHash(doc))
})
}
func TestLineNumberInInput(t *testing.T) {
// Scenario:
// line 5 in input was transformed to 3 lines in output
// line 7 in input was transformed to 2 lines in output
// line 8 in input was transformed to 2 lines in output
p := Batch{
lineNumberCorrections: []lineNumberCorrection{
{5, 2},
{7, 1},
{8, 1},
},
}
expectedInputLineNumbers := []int{
1,
2,
3,
4,
5,
5,
5,
6,
7,
7,
8,
8,
9,
10,
11,
12,
}
var inputlines [17]int
for lineno := 1; lineno <= 16; lineno++ {
inputlines[lineno] = p.RelativeLineNumberInInput(lineno)
//fmt.Println(p.RelativeLineNumberInInput(lineno), lineno)
}
assert.Equal(t, expectedInputLineNumbers, inputlines[1:])
}