| 1937 | } |
| 1938 | |
| 1939 | func TestBigIntBitSet(t *testing.T) { |
| 1940 | for _, test := range bitwiseTests { |
| 1941 | x := new(BigInt) |
| 1942 | x.SetString(test.x, 0) |
| 1943 | testBitset(t, x) |
| 1944 | x = new(BigInt) |
| 1945 | x.SetString(test.y, 0) |
| 1946 | testBitset(t, x) |
| 1947 | } |
| 1948 | for i, test := range bitsetTests { |
| 1949 | x := new(BigInt) |
| 1950 | x.SetString(test.x, 0) |
| 1951 | b := x.Bit(test.i) |
| 1952 | if b != test.b { |
| 1953 | t.Errorf("#%d got %v want %v", i, b, test.b) |
| 1954 | } |
| 1955 | } |
| 1956 | z := NewBigInt(1) |
| 1957 | z.SetBit(NewBigInt(0), 2, 1) |
| 1958 | if z.Cmp(NewBigInt(4)) != 0 { |
| 1959 | t.Errorf("destination leaked into result; got %s want 4", z) |
| 1960 | } |
| 1961 | } |
| 1962 | |
| 1963 | var tzbTests = []struct { |
| 1964 | in string |