-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lint: max_line_length supports utf-8
Signed-off-by: Yoan Blanc <[email protected]>
- Loading branch information
Showing
8 changed files
with
108 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package eclint is a set of linters to for the EditorConfig rules | ||
package eclint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package eclint_test | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"testing" | ||
|
||
"gitlab.com/greut/eclint" | ||
) | ||
|
||
func TestReadLines(t *testing.T) { | ||
tests := []struct { | ||
Name string | ||
File []byte | ||
LineFunc eclint.LineFunc | ||
}{ | ||
{ | ||
Name: "Empty file", | ||
File: []byte(""), | ||
LineFunc: func(i int, line []byte) error { | ||
if i != 0 || len(line) > 0 { | ||
return fmt.Errorf("more than one line found (%d), or non epmty line %q", i, line) | ||
} | ||
return nil | ||
}, | ||
}, { | ||
Name: "crlf", | ||
File: []byte("\r\n\r\n"), | ||
LineFunc: func(i int, line []byte) error { | ||
if i > 1 || len(line) > 2 { | ||
return fmt.Errorf("more than two lines found (%d), or non empty line %q", i, line) | ||
} | ||
return nil | ||
}, | ||
}, { | ||
Name: "cr", | ||
File: []byte("\r\r"), | ||
LineFunc: func(i int, line []byte) error { | ||
if i > 1 || len(line) > 2 { | ||
return fmt.Errorf("more than two lines found (%d), or non empty line %q", i, line) | ||
} | ||
return nil | ||
}, | ||
}, { | ||
Name: "lf", | ||
File: []byte("\n\n"), | ||
LineFunc: func(i int, line []byte) error { | ||
if i > 1 || len(line) > 2 { | ||
return fmt.Errorf("more than two lines found (%d), or non empty line %q", i, line) | ||
} | ||
return nil | ||
}, | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
tc := tc | ||
|
||
t.Run(tc.Name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
r := bytes.NewReader(tc.File) | ||
errs := eclint.ReadLines(r, tc.LineFunc) | ||
if len(errs) > 0 { | ||
t.Errorf("no errors were expected, got some. %s", errs[0]) | ||
return | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters