miller/internal/pkg/scan/digits_test.go
John Kerl e10fee0724
Improve type-inference performance (#809)
* To-do items for broader platform/go-version benchmarking

* neaten inferrer API

* extend type-inference unit-test cases

* Add benchmark scripts for comparing compiler versions

* mlr version in addition to mlr --version

* some go-benchmark files for Mac/Linux perf comparisons

* neaten perf-scripts

* merge

* type-scan optimization tests

* type-scan optimization infra

* test new inferrer

* mlr --time option

* include --cpuprofile and --traceprofile in on-line help

* sharpen inferred/deferred-type API distinction

* replace old inferrer with newer/faster

* update docs for new type-inferrer
2021-12-27 00:54:21 -05:00

57 lines
1.1 KiB
Go

package scan
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsDecimalDigit(t *testing.T) {
var c byte
for c = 0x00; c < 0xff; c++ {
if c >= '0' && c <= '9' {
assert.True(t, isDecimalDigit(c))
} else {
assert.False(t, isDecimalDigit(c))
}
}
}
func TestIsOctalDigit(t *testing.T) {
var c byte
for c = 0x00; c < 0xff; c++ {
if c >= '0' && c <= '7' {
assert.True(t, isOctalDigit(c))
} else {
assert.False(t, isOctalDigit(c))
}
}
}
func TestIsHexDigit(t *testing.T) {
var c byte
for c = 0x00; c < 0xff; c++ {
if c >= '0' && c <= '9' {
assert.True(t, isHexDigit(c))
} else if c >= 'a' && c <= 'f' {
assert.True(t, isHexDigit(c))
} else if c >= 'A' && c <= 'F' {
assert.True(t, isHexDigit(c))
} else {
assert.False(t, isHexDigit(c))
}
}
}
func TestIsFloatDigit(t *testing.T) {
var c byte
for c = 0x00; c < 0xff; c++ {
if c >= '0' && c <= '9' {
assert.True(t, isFloatDigit(c))
} else if c == '.' || c == '-' || c == '+' || c == 'e' || c == 'E' {
assert.True(t, isFloatDigit(c))
} else {
assert.False(t, isFloatDigit(c))
}
}
}