summaryrefslogtreecommitdiff
path: root/src/pkg/big/rat_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/big/rat_test.go')
-rw-r--r--src/pkg/big/rat_test.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/pkg/big/rat_test.go b/src/pkg/big/rat_test.go
index 8f42949b0..ae5c7c993 100644
--- a/src/pkg/big/rat_test.go
+++ b/src/pkg/big/rat_test.go
@@ -4,7 +4,11 @@
package big
-import "testing"
+import (
+ "bytes"
+ "fmt"
+ "testing"
+)
var setStringTests = []struct {
@@ -53,6 +57,29 @@ func TestRatSetString(t *testing.T) {
}
+func TestRatScan(t *testing.T) {
+ var buf bytes.Buffer
+ for i, test := range setStringTests {
+ x := new(Rat)
+ buf.Reset()
+ buf.WriteString(test.in)
+
+ _, err := fmt.Fscanf(&buf, "%v", x)
+ if err == nil != test.ok {
+ if test.ok {
+ t.Errorf("#%d error: %s", i, err.String())
+ } else {
+ t.Errorf("#%d expected error", i)
+ }
+ continue
+ }
+ if err == nil && x.RatString() != test.out {
+ t.Errorf("#%d got %s want %s", i, x.RatString(), test.out)
+ }
+ }
+}
+
+
var floatStringTests = []struct {
in string
prec int