MCPcopy Create free account
hub / github.com/cockroachdb/apd / testBitset

Function testBitset

bigint_test.go:1883–1918  ·  view source on GitHub ↗
(t *testing.T, x *BigInt)

Source from the content-addressed store, hash-verified

1881}
1882
1883func testBitset(t *testing.T, x *BigInt) {
1884 n := x.BitLen()
1885 z := new(BigInt).Set(x)
1886 z1 := new(BigInt).Set(x)
1887 for i := 0; i < n+10; i++ {
1888 old := z.Bit(i)
1889 old1 := altBit(z1, i)
1890 if old != old1 {
1891 t.Errorf("bitset: inconsistent value for Bit(%s, %d), got %v want %v", z1, i, old, old1)
1892 }
1893 z := new(BigInt).SetBit(z, i, 1)
1894 z1 := altSetBit(new(BigInt), z1, i, 1)
1895 if z.Bit(i) == 0 {
1896 t.Errorf("bitset: bit %d of %s got 0 want 1", i, x)
1897 }
1898 if z.Cmp(z1) != 0 {
1899 t.Errorf("bitset: inconsistent value after SetBit 1, got %s want %s", z, z1)
1900 }
1901 z.SetBit(z, i, 0)
1902 altSetBit(z1, z1, i, 0)
1903 if z.Bit(i) != 0 {
1904 t.Errorf("bitset: bit %d of %s got 1 want 0", i, x)
1905 }
1906 if z.Cmp(z1) != 0 {
1907 t.Errorf("bitset: inconsistent value after SetBit 0, got %s want %s", z, z1)
1908 }
1909 altSetBit(z1, z1, i, old)
1910 z.SetBit(z, i, old)
1911 if z.Cmp(z1) != 0 {
1912 t.Errorf("bitset: inconsistent value after SetBit old, got %s want %s", z, z1)
1913 }
1914 }
1915 if z.Cmp(x) != 0 {
1916 t.Errorf("bitset: got %s want %s", z, x)
1917 }
1918}
1919
1920var bitsetTests = []struct {
1921 x string

Callers 1

TestBigIntBitSetFunction · 0.85

Calls 7

altBitFunction · 0.85
altSetBitFunction · 0.85
BitLenMethod · 0.80
BitMethod · 0.80
SetBitMethod · 0.80
SetMethod · 0.45
CmpMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…