438
var ratNums = []string{
439
"-141592653589793238462643383279502884197169399375105820974944592307816406286",
440
"-1415926535897932384626433832795028841971",
446
"1415926535897932384626433832795028841971",
447
"141592653589793238462643383279502884197169399375105820974944592307816406286",
450
var ratDenoms = []string{
453
"7182818284590452353602874713526624977572",
454
"718281828459045235360287471352662497757247093699959574966967627724076630353",
457
func TestRatJSONEncoding(t *testing.T) {
458
for _, num := range ratNums {
459
for _, denom := range ratDenoms {
461
tx.SetString(num + "/" + denom)
462
b, err := json.Marshal(&tx)
464
t.Errorf("marshaling of %s failed: %s", &tx, err)
468
if err := json.Unmarshal(b, &rx); err != nil {
469
t.Errorf("unmarshaling of %s failed: %s", &tx, err)
472
if rx.Cmp(&tx) != 0 {
473
t.Errorf("JSON encoding of %s failed: got %s want %s", &tx, &rx, &tx)
479
func TestRatXMLEncoding(t *testing.T) {
480
for _, num := range ratNums {
481
for _, denom := range ratDenoms {
483
tx.SetString(num + "/" + denom)
484
b, err := xml.Marshal(&tx)
486
t.Errorf("marshaling of %s failed: %s", &tx, err)
490
if err := xml.Unmarshal(b, &rx); err != nil {
491
t.Errorf("unmarshaling of %s failed: %s", &tx, err)
494
if rx.Cmp(&tx) != 0 {
495
t.Errorf("XML encoding of %s failed: got %s want %s", &tx, &rx, &tx)
436
501
func TestIssue2379(t *testing.T) {
437
502
// 1) no aliasing
438
503
q := NewRat(3, 2)