7c63fff960
TomlDocument provides an optional TOML processing path where position informaiton is stored alongside a TomlTree. * Added Position struct * Revised TomlTree to contain position data * Added tomlValue to bind positions to values * Revised parser to emit position data * Revised token to use new Position struct * Added tests for new functionality * Bugfixed table array duplicate key handling * Applied gofmt to all code
32 lines
540 B
Go
32 lines
540 B
Go
// Testing support for go-toml
|
|
//
|
|
// BSD Licensed
|
|
// Copyright 2014 eric.t.anderton@gmail.com
|
|
package toml
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestPositionString(t *testing.T) {
|
|
p := Position{123, 456}
|
|
expected := "(123, 456)"
|
|
value := p.String()
|
|
|
|
if value != expected {
|
|
t.Errorf("Expected %v, got %v instead", expected, value)
|
|
}
|
|
}
|
|
|
|
func TestInvalid(t *testing.T) {
|
|
for i, v := range []Position{
|
|
Position{0, 1234},
|
|
Position{1234, 0},
|
|
Position{0, 0},
|
|
} {
|
|
if !v.Invalid() {
|
|
t.Errorf("Position at %v is valid: %v", i, v)
|
|
}
|
|
}
|
|
}
|