| 2743 | } |
| 2744 | |
| 2745 | func TestBigIntJSONEncoding(t *testing.T) { |
| 2746 | for _, test := range encodingTests { |
| 2747 | for _, sign := range []string{"", "+", "-"} { |
| 2748 | x := sign + test |
| 2749 | var tx BigInt |
| 2750 | tx.SetString(x, 10) |
| 2751 | b, err := json.Marshal(&tx) |
| 2752 | if err != nil { |
| 2753 | t.Errorf("marshaling of %s failed: %s", &tx, err) |
| 2754 | continue |
| 2755 | } |
| 2756 | var rx BigInt |
| 2757 | if err := json.Unmarshal(b, &rx); err != nil { |
| 2758 | t.Errorf("unmarshaling of %s failed: %s", &tx, err) |
| 2759 | continue |
| 2760 | } |
| 2761 | if rx.Cmp(&tx) != 0 { |
| 2762 | t.Errorf("JSON encoding of %s failed: got %s want %s", &tx, &rx, &tx) |
| 2763 | } |
| 2764 | } |
| 2765 | } |
| 2766 | } |
| 2767 | |
| 2768 | func TestBigIntXMLEncoding(t *testing.T) { |
| 2769 | for _, test := range encodingTests { |