mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Increased test coverage, remove dead code
This commit is contained in:
@@ -38,6 +38,29 @@ func TestSimpleKeyStringValues(t *testing.T) {
|
||||
// NL
|
||||
lx = lex("foo='bar'\r\n")
|
||||
expect(t, lx, expectedItems)
|
||||
lx = lex("foo=\t'bar'\t")
|
||||
expect(t, lx, expectedItems)
|
||||
}
|
||||
|
||||
func TestComplexStringValues(t *testing.T) {
|
||||
expectedItems := []item{
|
||||
{itemKey, "foo", 1},
|
||||
{itemString, "bar\\r\\n \\t", 1},
|
||||
{itemEOF, "", 2},
|
||||
}
|
||||
|
||||
lx := lex("foo = 'bar\\r\\n \\t'")
|
||||
expect(t, lx, expectedItems)
|
||||
}
|
||||
|
||||
func TestBinaryString(t *testing.T) {
|
||||
expectedItems := []item{
|
||||
{itemKey, "foo", 1},
|
||||
{itemString, "\\x22", 1},
|
||||
{itemEOF, "", 1},
|
||||
}
|
||||
lx := lex("foo = \\x22")
|
||||
expect(t, lx, expectedItems)
|
||||
}
|
||||
|
||||
func TestSimpleKeyIntegerValues(t *testing.T) {
|
||||
@@ -96,6 +119,21 @@ func TestComments(t *testing.T) {
|
||||
expect(t, lx, expectedItems)
|
||||
}
|
||||
|
||||
func TestTopValuesWithComments(t *testing.T) {
|
||||
expectedItems := []item{
|
||||
{itemKey, "foo", 1},
|
||||
{itemInteger, "123", 1},
|
||||
{itemCommentStart, "", 1},
|
||||
{itemText, " This is a comment", 1},
|
||||
{itemEOF, "", 1},
|
||||
}
|
||||
|
||||
lx := lex("foo = 123 // This is a comment")
|
||||
expect(t, lx, expectedItems)
|
||||
lx = lex("foo=123 # This is a comment")
|
||||
expect(t, lx, expectedItems)
|
||||
}
|
||||
|
||||
func TestArrays(t *testing.T) {
|
||||
expectedItems := []item{
|
||||
{itemKey, "foo", 1},
|
||||
@@ -153,7 +191,7 @@ func TestMultilineArrays(t *testing.T) {
|
||||
var mlArrayNoSep = `
|
||||
# top level comment
|
||||
foo = [
|
||||
1
|
||||
1 // foo
|
||||
2
|
||||
3
|
||||
'bar'
|
||||
@@ -168,6 +206,8 @@ func TestMultilineArraysNoSep(t *testing.T) {
|
||||
{itemKey, "foo", 3},
|
||||
{itemArrayStart, "", 3},
|
||||
{itemInteger, "1", 4},
|
||||
{itemCommentStart, "", 4},
|
||||
{itemText, " foo", 4},
|
||||
{itemInteger, "2", 5},
|
||||
{itemInteger, "3", 6},
|
||||
{itemString, "bar", 7},
|
||||
@@ -197,8 +237,8 @@ func TestSimpleMap(t *testing.T) {
|
||||
|
||||
var mlMap = `
|
||||
foo = {
|
||||
ip = '127.0.0.1'
|
||||
port= 4242
|
||||
ip = '127.0.0.1' # the IP
|
||||
port= 4242 // the port
|
||||
}
|
||||
`
|
||||
|
||||
@@ -208,8 +248,12 @@ func TestMultilineMap(t *testing.T) {
|
||||
{itemMapStart, "", 2},
|
||||
{itemKey, "ip", 3},
|
||||
{itemString, "127.0.0.1", 3},
|
||||
{itemCommentStart, "", 3},
|
||||
{itemText, " the IP", 3},
|
||||
{itemKey, "port", 4},
|
||||
{itemInteger, "4242", 4},
|
||||
{itemCommentStart, "", 4},
|
||||
{itemText, " the port", 4},
|
||||
{itemMapEnd, "", 5},
|
||||
{itemEOF, "", 5},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user