a3d46d52a8
test / release-check (push) Has been skipped
test / 1.25/macos-14 (push) Has been cancelled
test / 1.25/macos-latest (push) Has been cancelled
test / 1.25/ubuntu-latest (push) Has been cancelled
test / 1.25/windows-latest (push) Has been cancelled
test / 1.26/macos-14 (push) Has been cancelled
test / 1.26/macos-latest (push) Has been cancelled
test / 1.26/ubuntu-latest (push) Has been cancelled
test / 1.26/windows-latest (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
45 lines
648 B
Go
45 lines
648 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.ostiwe.com/ostiwe/go-toml/v2/internal/assert"
|
|
)
|
|
|
|
func TestConvert(t *testing.T) {
|
|
examples := []struct {
|
|
name string
|
|
input string
|
|
expected string
|
|
errors bool
|
|
}{
|
|
{
|
|
name: "valid toml",
|
|
input: `
|
|
mytoml.a = 42.0
|
|
`,
|
|
expected: `[mytoml]
|
|
a = 42.0
|
|
`,
|
|
},
|
|
{
|
|
name: "invalid toml",
|
|
input: `[what`,
|
|
errors: true,
|
|
},
|
|
}
|
|
|
|
for _, e := range examples {
|
|
b := new(bytes.Buffer)
|
|
err := convert(strings.NewReader(e.input), b)
|
|
if e.errors {
|
|
assert.Error(t, err)
|
|
} else {
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, e.expected, b.String())
|
|
}
|
|
}
|
|
}
|