feat: add the check_output_matches
plugin #5
2 changed files with 12 additions and 7 deletions
|
@ -116,7 +116,7 @@ func ParseRange(input string) (*Range, error) {
|
|||
case rpsInit:
|
||||
if curRune == '@' {
|
||||
parsed.inside = true
|
||||
index += 1
|
||||
index++
|
||||
}
|
||||
state = rpsExpectStart
|
||||
|
||||
|
@ -132,7 +132,7 @@ func ParseRange(input string) (*Range, error) {
|
|||
startOfStart = index
|
||||
state = rpsInStart
|
||||
}
|
||||
index += 1
|
||||
index++
|
||||
|
||||
case rpsInStart:
|
||||
switch curRune {
|
||||
|
@ -146,13 +146,13 @@ func ParseRange(input string) (*Range, error) {
|
|||
default:
|
||||
strBuilder.WriteRune(curRune)
|
||||
}
|
||||
index += 1
|
||||
index++
|
||||
|
||||
case rpsExpectColon:
|
||||
switch curRune {
|
||||
case ':':
|
||||
state = rpsExpectEnd
|
||||
index += 1
|
||||
index++
|
||||
default:
|
||||
return nil, parseError(input, index, "expected ':'")
|
||||
}
|
||||
|
@ -163,10 +163,15 @@ func ParseRange(input string) (*Range, error) {
|
|||
|
||||
case rpsInEnd:
|
||||
strBuilder.WriteRune(curRune)
|
||||
index += 1
|
||||
index++
|
||||
}
|
||||
}
|
||||
|
||||
if state == rpsInStart {
|
||||
// The range was a single value, so that's the upper bound.
|
||||
parsed.start = "0"
|
||||
state = rpsInEnd
|
||||
}
|
||||
if state != rpsInEnd {
|
||||
return nil, parseError(input, index, "unexpected end of input")
|
||||
}
|
||||
|
|
|
@ -81,12 +81,14 @@ func TestRangeParserOk(t *testing.T) {
|
|||
{in: ":123", out: Range{start: "0", end: "123"}},
|
||||
{in: "0:123", out: Range{start: "0", end: "123"}},
|
||||
{in: "~:123", out: Range{start: "", end: "123"}},
|
||||
{in: "1", out: Range{start: "0", end: "1"}},
|
||||
{in: "@:0", out: Range{start: "0", end: "0", inside: true}},
|
||||
{in: "@0:0", out: Range{start: "0", end: "0", inside: true}},
|
||||
{in: "@~:0", out: Range{start: "", end: "0", inside: true}},
|
||||
{in: "@:123", out: Range{start: "0", end: "123", inside: true}},
|
||||
{in: "@0:123", out: Range{start: "0", end: "123", inside: true}},
|
||||
{in: "@~:123", out: Range{start: "", end: "123", inside: true}},
|
||||
{in: "@1", out: Range{start: "0", end: "1", inside: true}},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
@ -106,12 +108,10 @@ func TestRangeParserError(t *testing.T) {
|
|||
{in: ":", errPos: 1},
|
||||
{in: "x:1", errPos: 0},
|
||||
{in: ":~", errPos: 1},
|
||||
{in: "1", errPos: 1},
|
||||
{in: "@", errPos: 1},
|
||||
{in: "@:", errPos: 2},
|
||||
{in: "@x:1", errPos: 1},
|
||||
{in: "@:~", errPos: 2},
|
||||
{in: "@1", errPos: 2},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
Loading…
Reference in a new issue