Changes since 5.5.1: * Fixed command line parsing for the --only option. * Improved alignment of variable values in Makefiles. * Code cleanup: better abstraction in the tests.
60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
check "gopkg.in/check.v1"
|
|
)
|
|
|
|
func (s *Suite) Test_convertToLogicalLines_no_continuation(c *check.C) {
|
|
rawText := "" +
|
|
"first line\n" +
|
|
"second line\n"
|
|
|
|
lines := convertToLogicalLines("fname_nocont", rawText, false)
|
|
|
|
c.Check(lines, check.HasLen, 2)
|
|
c.Check(lines[0].String(), equals, "fname_nocont:1: first line")
|
|
c.Check(lines[1].String(), equals, "fname_nocont:2: second line")
|
|
}
|
|
|
|
func (s *Suite) Test_convertToLogicalLines_continuation(c *check.C) {
|
|
rawText := "" +
|
|
"first line \\\n" +
|
|
"second line\n" +
|
|
"third\n"
|
|
|
|
lines := convertToLogicalLines("fname_cont", rawText, true)
|
|
|
|
c.Check(lines, check.HasLen, 2)
|
|
c.Check(lines[0].String(), equals, "fname_cont:1--2: first line second line")
|
|
c.Check(lines[1].String(), equals, "fname_cont:3: third")
|
|
}
|
|
|
|
func (s *Suite) Test_convertToLogicalLines_continuationInLastLine(c *check.C) {
|
|
t := s.Init(c)
|
|
|
|
rawText := "" +
|
|
"last line\\"
|
|
|
|
lines := convertToLogicalLines("fname_contlast", rawText, true)
|
|
|
|
c.Check(lines, check.HasLen, 1)
|
|
c.Check(lines[0].String(), equals, "fname_contlast:1: last line\\")
|
|
t.CheckOutputLines(
|
|
"ERROR: fname_contlast:EOF: File must end with a newline.")
|
|
}
|
|
|
|
func (s *Suite) Test_splitRawLine(c *check.C) {
|
|
leadingWhitespace, text, trailingWhitespace, continuation := splitRawLine("\n")
|
|
|
|
c.Check(leadingWhitespace, equals, "")
|
|
c.Check(text, equals, "")
|
|
c.Check(trailingWhitespace, equals, "")
|
|
c.Check(continuation, equals, "")
|
|
|
|
leadingWhitespace, text, trailingWhitespace, continuation = splitRawLine("\tword \\\n")
|
|
|
|
c.Check(leadingWhitespace, equals, "\t")
|
|
c.Check(text, equals, "word")
|
|
c.Check(trailingWhitespace, equals, " ")
|
|
c.Check(continuation, equals, "\\")
|
|
}
|