func TestDecodeBigReal(t *testing.T) { var hugeFloat big.Float hugeFloat.SetString("3.14e+99999") data := fmt.Sprintf("<real>%s</real>", hugeFloat.String()) decoder := baseDecoder{nil, xml.NewDecoder(bytes.NewReader([]byte(data)))} value, err := decoder.NextValue() assert.NoError(t, err) assert.Equal(t, hugeFloat, value) }
// Read lines from in as big.Float func read(in io.Reader, xs []big.Float) []big.Float { scanner := bufio.NewScanner(in) for scanner.Scan() { var x big.Float x.SetPrec(*prec) text := strings.TrimSpace(scanner.Text()) if len(text) == 0 || text[0] == '#' { continue } _, ok := x.SetString(text) if !ok { log.Fatalf("Failed to parse line %q", text) } xs = append(xs, x) } if err := scanner.Err(); err != nil { log.Fatalf("Error reading input: %v", err) } return xs }