Documentation ¶
Overview ¶
Package spec provides the test specifications for the CountLines function.
Alternate implementations of CountLines function must pass the test as well.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DataCountLines = []struct { Reason string // Reason on failure Input string // Input data ExpectOut int // Expected output }{ { Reason: "'<EOF>' --> empty file should be zero", Input: "", ExpectOut: 0, }, { Reason: "'Hello<EOF>' --> single line without line break should be one", Input: "Hello", ExpectOut: 1, }, { Reason: "'Hello\\n<EOF>' --> single line with line break should be one", Input: "Hello\n", ExpectOut: 1, }, { Reason: "'\\n<EOF>' --> single line break should be one", Input: "\n", ExpectOut: 1, }, { Reason: "'\\n\\n<EOF>' --> two line breaks should be two", Input: "\n\n", ExpectOut: 2, }, { Reason: "'\\nHello<EOF>' --> one line break and one line without line break should be two", Input: "\nHello", ExpectOut: 2, }, { Reason: "'\\nHello\\n<EOF>' --> one line break and one line with line break should be two", Input: "\nHello\n", ExpectOut: 2, }, { Reason: "'\\n\\nHello<EOF>' --> two line breaks and one line without line break should be three", Input: "\n\nHello", ExpectOut: 3, }, { Reason: "'\\n\\nHello\\n<EOF>' --> two line breaks and one line with line break should be three", Input: "\n\nHello\n", ExpectOut: 3, }, { Reason: "'<large line>\\n<EOF>' --> long string with a line break should be onw", Input: GetStrDummyLines(bufio.MaxScanTokenSize*2, 1), ExpectOut: 1, }, { Reason: "'<large line>\\n<large line>\\n<EOF>' --> long string but two lines should be two", Input: GetStrDummyLines(bufio.MaxScanTokenSize*2, 2), ExpectOut: 2, }, }
DataCountLines is the data provider for the CountLines function to check if the specifications are covered. Alternate functions must pass the test with this data as well.
Functions ¶
func GetStrDummyLines ¶
GetStrDummyLines returns a string with the given size and number of lines. 'sizeLine' is the size of each line. 'numLines' is the number of lines.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.