MCPcopy
hub / github.com/hashicorp/hcl / TestPosScanner

Function TestPosScanner

pos_scanner_test.go:14–196  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestPosScanner(t *testing.T) {
15 tests := map[string]struct {
16 Input string
17 Want []Range
18 WantToks [][]byte
19 }{
20 "empty": {
21 "",
22 []Range{},
23 [][]byte{},
24 },
25 "single line": {
26 "hello",
27 []Range{
28 {
29 Start: Pos{Byte: 0, Line: 1, Column: 1},
30 End: Pos{Byte: 5, Line: 1, Column: 6},
31 },
32 },
33 [][]byte{
34 []byte("hello"),
35 },
36 },
37 "single line with trailing UNIX newline": {
38 "hello\n",
39 []Range{
40 {
41 Start: Pos{Byte: 0, Line: 1, Column: 1},
42 End: Pos{Byte: 5, Line: 1, Column: 6},
43 },
44 },
45 [][]byte{
46 []byte("hello"),
47 },
48 },
49 "single line with trailing Windows newline": {
50 "hello\r\n",
51 []Range{
52 {
53 Start: Pos{Byte: 0, Line: 1, Column: 1},
54 End: Pos{Byte: 5, Line: 1, Column: 6},
55 },
56 },
57 [][]byte{
58 []byte("hello"),
59 },
60 },
61 "two lines with UNIX newline": {
62 "hello\nworld",
63 []Range{
64 {
65 Start: Pos{Byte: 0, Line: 1, Column: 1},
66 End: Pos{Byte: 5, Line: 1, Column: 6},
67 },
68 {
69 Start: Pos{Byte: 6, Line: 2, Column: 1},
70 End: Pos{Byte: 11, Line: 2, Column: 6},
71 },

Callers

nothing calls this directly

Calls 6

ScanMethod · 0.95
RangeMethod · 0.95
BytesMethod · 0.95
ErrMethod · 0.95
NewRangeScannerFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected