* skip empty lines to avoid issue of #630 * add tests on empty lines and comms
This commit is contained in:
parent
da84805f5f
commit
a3d00fe130
3 changed files with 21 additions and 0 deletions
|
@ -73,6 +73,9 @@ func FileInit(fileFolder string, filename string, fileType string) error {
|
|||
if strings.HasPrefix(scanner.Text(), "#") { // allow comments
|
||||
continue
|
||||
}
|
||||
if len(scanner.Text()) == 0 { //skip empty lines
|
||||
continue
|
||||
}
|
||||
switch fileType {
|
||||
case "regex", "regexp":
|
||||
dataFileRegex[filename] = append(dataFileRegex[filename], regexp.MustCompile(scanner.Text()))
|
||||
|
|
|
@ -178,6 +178,12 @@ func TestFileInit(t *testing.T) {
|
|||
types: "string",
|
||||
result: 3,
|
||||
},
|
||||
{
|
||||
name: "file with type:string and empty lines + commentaries",
|
||||
filename: "test_empty_line.txt",
|
||||
types: "string",
|
||||
result: 3,
|
||||
},
|
||||
{
|
||||
name: "file with type:re",
|
||||
filename: "test_data_re.txt",
|
||||
|
|
12
pkg/exprhelpers/tests/test_empty_line.txt
Normal file
12
pkg/exprhelpers/tests/test_empty_line.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
foo
|
||||
|
||||
#toto
|
||||
|
||||
|
||||
bar
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
baz
|
Loading…
Reference in a new issue