| 1 |
package tomlscip-go gomod github.com/komkom/toml . `github.com/komkom/toml/internal`/ |
| 2 |
|
| 3 |
import ( |
| 4 |
"testingscip-go gomod github.com/golang/go/src go1.15 testing/" |
| 5 |
|
| 6 |
"github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/" |
| 7 |
"github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/require`/" |
| 8 |
) |
| 9 |
|
| 10 |
func TestConvertscip-go gomod github.com/komkom/toml . `github.com/komkom/toml/internal`/TestConvert().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) { |
| 11 |
|
| 12 |
tests := []struct { |
| 13 |
value string |
| •14 |
expected int64 |
| 15 |
}{ |
| 16 |
{ |
| 17 |
value: `0x12AFE`, |
| 18 |
expected: 76542, |
| 19 |
}, |
| 20 |
{ |
| 21 |
value: `0x00012AFE`, |
| 22 |
expected: 76542, |
| 23 |
}, |
| 24 |
{ |
| 25 |
value: `0o67`, |
| 26 |
expected: 55, |
| 27 |
}, |
| 28 |
{ |
| 29 |
value: `0o25677`, |
| 30 |
expected: 11199, |
| 31 |
}, |
| 32 |
{ |
| 33 |
value: `0b11`, |
| 34 |
expected: 3, |
| 35 |
}, |
| 36 |
{ |
| 37 |
value: `0b101`, |
| 38 |
expected: 5, |
| 39 |
}, |
| 40 |
{ |
| 41 |
value: `0b0011`, |
| 42 |
expected: 3, |
| 43 |
}, |
| 44 |
} |
| 45 |
|
| 46 |
var err error |
| 47 |
for _, ts := range tests { |
| 48 |
|
| •49 |
var total int64 |
| 50 |
|
| 51 |
for _, r := range ts.value[2:] { |
| 52 |
if ts.value[:2] == `0x` { |
| 53 |
total, err = addNumberscip-go gomod github.com/komkom/toml . `github.com/komkom/toml/internal`/addNumber().(r, total, HexNumberTypescip-go gomod github.com/komkom/toml . `github.com/komkom/toml/internal`/HexNumberType.) |
| 54 |
requirescip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 55 |
} |
| 56 |
if ts.value[:2] == `0o` { |
| 57 |
total, err = addNumberscip-go gomod github.com/komkom/toml . `github.com/komkom/toml/internal`/addNumber().(r, total, OctalNumberTypescip-go gomod github.com/komkom/toml . `github.com/komkom/toml/internal`/OctalNumberType.) |
| 58 |
requirescip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 59 |
} |
| 60 |
if ts.value[:2] == `0b` { |
| 61 |
total, err = addNumberscip-go gomod github.com/komkom/toml . `github.com/komkom/toml/internal`/addNumber().(r, total, BinNumberTypescip-go gomod github.com/komkom/toml . `github.com/komkom/toml/internal`/BinNumberType.) |
| 62 |
requirescip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 63 |
} |
| 64 |
} |
| 65 |
assertscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.6.1 `github.com/stretchr/testify/assert`/Equal().(t, ts.expected, total) |
| 66 |
} |
| 67 |
} |