MCPcopy
hub / github.com/google/mangle / TestFloat64ToString

Function TestFloat64ToString

functional/functional_test.go:640–663  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

638}
639
640func TestFloat64ToString(t *testing.T) {
641 tests := []struct {
642 input []ast.BaseTerm
643 want ast.Constant
644 }{
645 {[]ast.BaseTerm{ast.Float64(123)}, ast.String("123")},
646 {[]ast.BaseTerm{ast.Float64(-3.14)}, ast.String("-3.14")},
647 {[]ast.BaseTerm{ast.Float64(1000000)}, ast.String("1000000")},
648 {[]ast.BaseTerm{ast.Float64(1000001)}, ast.String("1000001")},
649 {[]ast.BaseTerm{ast.Float64(0.123456789)}, ast.String("0.123456789")},
650 {[]ast.BaseTerm{ast.Float64(0.999999999)}, ast.String("0.999999999")},
651 }
652
653 for _, test := range tests {
654 term := ast.ApplyFn{symbols.Float64ToString, test.input}
655 got, err := EvalExpr(term, ast.ConstSubstMap{})
656 if err != nil {
657 t.Fatal(err)
658 }
659 if got != test.want {
660 t.Errorf("EvalExpr(%v)=%v want %v.", term, got, test.want)
661 }
662 }
663}
664
665func TestFloat64ToStringFailure(t *testing.T) {
666 tests := [][]ast.BaseTerm{

Callers

nothing calls this directly

Calls 3

Float64Function · 0.92
StringFunction · 0.92
EvalExprFunction · 0.85

Tested by

no test coverage detected