-rw-r--r-- 21653 cryptattacktester-20231020/biginttest.cpp raw
// XXX: test &
// XXX: test +=
// XXX: test -=
// XXX: test *=
// XXX: test /=
// XXX: test %=
// XXX: test <<=
// XXX: test >>=
#include <cassert>
#include <iomanip>
#include "random.h"
#include "bigint.h"
using namespace std;
#define POOL 100
static void test_misc()
{
assert(bigint("314159") == 314159);
assert(bigint("314159",11) == 503303);
assert(bigint(std::string("314159")) == 314159);
assert(bigint("314159")+bigint("271828") == 314159+271828);
assert(bigint("314159")*bigint("271828") == 314159*(bigint) 271828);
assert(bigint("314159")*bigint("271828") == 314159*(bigint) 271828);
assert(bigint("1014261808884971")*bigint("309741787186437") == bigint("314159265358979323846264338327"));
assert(bigint("1014261808884971")*bigint("309741787186437") != bigint("314159265358979323846264338328"));
assert((bigint("1014261808884971")*bigint("309741787186437")).get_str() == "314159265358979323846264338327");
assert((bigint("1014261808884971")*bigint("-309741787186437")).get_str() == "-314159265358979323846264338327");
assert(bigint("0").get_str() == "0");
assert(binomial("12345",37) == "1671016547199213017327960539628973339760233654371421030637308064910480247256444038244887018273649414324982910");
assert(nbits(0) == 1);
assert(nbits(1) == 1);
assert(nbits(2) == 2);
assert(nbits(3) == 2);
assert(nbits(4) == 3);
assert(nbits(5) == 3);
assert(nbits(6) == 3);
assert(nbits(7) == 3);
assert(nbits(8) == 4);
}
vector<int> i0(POOL);
vector<long> i1(POOL);
vector<long long> i2(POOL);
vector<unsigned int> i3(POOL);
vector<unsigned long> i4(POOL);
vector<unsigned long long> i5(POOL);
vector<bigint> b0(POOL);
vector<bigint> b1(POOL);
vector<bigint> b2(POOL);
vector<bigint> b3(POOL);
vector<bigint> b4(POOL);
vector<bigint> b5(POOL);
static void init_arrays()
{
for (bigint j = 0;j < POOL;++j) {
i0.at(j) = random_int();
i1.at(j) = random_long();
i2.at(j) = random_longlong();
i3.at(j) = random_uint();
i4.at(j) = random_ulong();
i5.at(j) = random_ulonglong();
b0.at(j) = bigint(i0.at(j));
b1.at(j) = bigint(i1.at(j));
b2.at(j) = bigint(i2.at(j));
b3.at(j) = bigint(i3.at(j));
b4.at(j) = bigint(i4.at(j));
b5.at(j) = bigint(i5.at(j));
}
}
static void print_minmax()
{
auto mini0 = i0.at(0); for (bigint j = 1;j < POOL;++j) mini0 = min(mini0,i0.at(j)); cout << "min i0 " << setw(20) << mini0 << "\n";
auto maxi0 = i0.at(0); for (bigint j = 1;j < POOL;++j) maxi0 = max(maxi0,i0.at(j)); cout << "max i0 " << setw(20) << maxi0 << "\n";
auto mini1 = i1.at(0); for (bigint j = 1;j < POOL;++j) mini1 = min(mini1,i1.at(j)); cout << "min i1 " << setw(20) << mini1 << "\n";
auto maxi1 = i1.at(0); for (bigint j = 1;j < POOL;++j) maxi1 = max(maxi1,i1.at(j)); cout << "max i1 " << setw(20) << maxi1 << "\n";
auto mini2 = i2.at(0); for (bigint j = 1;j < POOL;++j) mini2 = min(mini2,i2.at(j)); cout << "min i2 " << setw(20) << mini2 << "\n";
auto maxi2 = i2.at(0); for (bigint j = 1;j < POOL;++j) maxi2 = max(maxi2,i2.at(j)); cout << "max i2 " << setw(20) << maxi2 << "\n";
auto mini3 = i3.at(0); for (bigint j = 1;j < POOL;++j) mini3 = min(mini3,i3.at(j)); cout << "min i3 " << setw(20) << mini3 << "\n";
auto maxi3 = i3.at(0); for (bigint j = 1;j < POOL;++j) maxi3 = max(maxi3,i3.at(j)); cout << "max i3 " << setw(20) << maxi3 << "\n";
auto mini4 = i4.at(0); for (bigint j = 1;j < POOL;++j) mini4 = min(mini4,i4.at(j)); cout << "min i4 " << setw(20) << mini4 << "\n";
auto maxi4 = i4.at(0); for (bigint j = 1;j < POOL;++j) maxi4 = max(maxi4,i4.at(j)); cout << "max i4 " << setw(20) << maxi4 << "\n";
auto mini5 = i5.at(0); for (bigint j = 1;j < POOL;++j) mini5 = min(mini5,i5.at(j)); cout << "min i5 " << setw(20) << mini5 << "\n";
auto maxi5 = i5.at(0); for (bigint j = 1;j < POOL;++j) maxi5 = max(maxi5,i5.at(j)); cout << "max i5 " << setw(20) << maxi5 << "\n";
}
static void test_leftshift()
{
for (bigint j = 0;j < POOL;++j)
for (long long s = 0;s < 100;++s) {
if (s < 20) assert((b0.at(j)<<s) == ((bigint) i0.at(j)<<s));
assert((b0.at(j)<<s) == (b0.at(j)<<bigint(s)));
assert((b0.at(j)<<s) == (i0.at(j)<<bigint(s)));
assert((b0.at(j)<<s) == (b0.at(j)<<int(s)));
assert((b0.at(j)<<s) == (b0.at(j)<<long(s)));
assert((b0.at(j)<<s) == (b0.at(j)<<(unsigned int)(s)));
assert((b0.at(j)<<s) == (b0.at(j)<<(unsigned long)(s)));
assert((b0.at(j)<<s) == (b0.at(j)<<(unsigned long long)(s)));
assert((b1.at(j)<<s) == (b1.at(j)<<bigint(s)));
assert((b1.at(j)<<s) == (i1.at(j)<<bigint(s)));
assert((b1.at(j)<<s) == (b1.at(j)<<int(s)));
assert((b1.at(j)<<s) == (b1.at(j)<<long(s)));
assert((b1.at(j)<<s) == (b1.at(j)<<(unsigned int)(s)));
assert((b1.at(j)<<s) == (b1.at(j)<<(unsigned long)(s)));
assert((b1.at(j)<<s) == (b1.at(j)<<(unsigned long long)(s)));
assert((b2.at(j)<<s) == (b2.at(j)<<bigint(s)));
assert((b2.at(j)<<s) == (i2.at(j)<<bigint(s)));
assert((b2.at(j)<<s) == (b2.at(j)<<int(s)));
assert((b2.at(j)<<s) == (b2.at(j)<<long(s)));
assert((b2.at(j)<<s) == (b2.at(j)<<(unsigned int)(s)));
assert((b2.at(j)<<s) == (b2.at(j)<<(unsigned long)(s)));
assert((b2.at(j)<<s) == (b2.at(j)<<(unsigned long long)(s)));
assert((b3.at(j)<<s) == (b3.at(j)<<bigint(s)));
assert((b3.at(j)<<s) == (i3.at(j)<<bigint(s)));
assert((b3.at(j)<<s) == (b3.at(j)<<int(s)));
assert((b3.at(j)<<s) == (b3.at(j)<<long(s)));
assert((b3.at(j)<<s) == (b3.at(j)<<(unsigned int)(s)));
assert((b3.at(j)<<s) == (b3.at(j)<<(unsigned long)(s)));
assert((b3.at(j)<<s) == (b3.at(j)<<(unsigned long long)(s)));
assert((b4.at(j)<<s) == (b4.at(j)<<bigint(s)));
assert((b4.at(j)<<s) == (i4.at(j)<<bigint(s)));
assert((b4.at(j)<<s) == (b4.at(j)<<int(s)));
assert((b4.at(j)<<s) == (b4.at(j)<<long(s)));
assert((b4.at(j)<<s) == (b4.at(j)<<(unsigned int)(s)));
assert((b4.at(j)<<s) == (b4.at(j)<<(unsigned long)(s)));
assert((b4.at(j)<<s) == (b4.at(j)<<(unsigned long long)(s)));
assert((b5.at(j)<<s) == (b5.at(j)<<bigint(s)));
assert((b5.at(j)<<s) == (i5.at(j)<<bigint(s)));
assert((b5.at(j)<<s) == (b5.at(j)<<int(s)));
assert((b5.at(j)<<s) == (b5.at(j)<<long(s)));
assert((b5.at(j)<<s) == (b5.at(j)<<(unsigned int)(s)));
assert((b5.at(j)<<s) == (b5.at(j)<<(unsigned long)(s)));
assert((b5.at(j)<<s) == (b5.at(j)<<(unsigned long long)(s)));
}
}
static void test_rightshift()
{
for (bigint j = 0;j < POOL;++j)
for (long long s = 0;s < 100;++s) {
if (s < 20) assert((b0.at(j)<<s) == ((bigint) i0.at(j)<<s));
if (s < 32) assert((b0.at(j)>>s) == (i0.at(j)>>s));
assert((b0.at(j)>>s) == (b0.at(j)>>bigint(s)));
assert((b0.at(j)>>s) == (i0.at(j)>>bigint(s)));
assert((b0.at(j)>>s) == (b0.at(j)>>int(s)));
assert((b0.at(j)>>s) == (b0.at(j)>>long(s)));
assert((b0.at(j)>>s) == (b0.at(j)>>(unsigned int)(s)));
assert((b0.at(j)>>s) == (b0.at(j)>>(unsigned long)(s)));
assert((b0.at(j)>>s) == (b0.at(j)>>(unsigned long long)(s)));
if (s < 32) assert((b1.at(j)>>s) == (i1.at(j)>>s));
assert((b1.at(j)>>s) == (b1.at(j)>>bigint(s)));
assert((b1.at(j)>>s) == (i1.at(j)>>bigint(s)));
assert((b1.at(j)>>s) == (b1.at(j)>>int(s)));
assert((b1.at(j)>>s) == (b1.at(j)>>long(s)));
assert((b1.at(j)>>s) == (b1.at(j)>>(unsigned int)(s)));
assert((b1.at(j)>>s) == (b1.at(j)>>(unsigned long)(s)));
assert((b1.at(j)>>s) == (b1.at(j)>>(unsigned long long)(s)));
if (s < 32) assert((b2.at(j)>>s) == (i2.at(j)>>s));
assert((b2.at(j)>>s) == (b2.at(j)>>bigint(s)));
assert((b2.at(j)>>s) == (i2.at(j)>>bigint(s)));
assert((b2.at(j)>>s) == (b2.at(j)>>int(s)));
assert((b2.at(j)>>s) == (b2.at(j)>>long(s)));
assert((b2.at(j)>>s) == (b2.at(j)>>(unsigned int)(s)));
assert((b2.at(j)>>s) == (b2.at(j)>>(unsigned long)(s)));
assert((b2.at(j)>>s) == (b2.at(j)>>(unsigned long long)(s)));
if (s < 32) assert((b3.at(j)>>s) == (i3.at(j)>>s));
assert((b3.at(j)>>s) == (b3.at(j)>>bigint(s)));
assert((b3.at(j)>>s) == (i3.at(j)>>bigint(s)));
assert((b3.at(j)>>s) == (b3.at(j)>>int(s)));
assert((b3.at(j)>>s) == (b3.at(j)>>long(s)));
assert((b3.at(j)>>s) == (b3.at(j)>>(unsigned int)(s)));
assert((b3.at(j)>>s) == (b3.at(j)>>(unsigned long)(s)));
assert((b3.at(j)>>s) == (b3.at(j)>>(unsigned long long)(s)));
if (s < 32) assert((b4.at(j)>>s) == (i4.at(j)>>s));
assert((b4.at(j)>>s) == (b4.at(j)>>bigint(s)));
assert((b4.at(j)>>s) == (i4.at(j)>>bigint(s)));
assert((b4.at(j)>>s) == (b4.at(j)>>int(s)));
assert((b4.at(j)>>s) == (b4.at(j)>>long(s)));
assert((b4.at(j)>>s) == (b4.at(j)>>(unsigned int)(s)));
assert((b4.at(j)>>s) == (b4.at(j)>>(unsigned long)(s)));
assert((b4.at(j)>>s) == (b4.at(j)>>(unsigned long long)(s)));
if (s < 32) assert((b5.at(j)>>s) == (i5.at(j)>>s));
assert((b5.at(j)>>s) == (b5.at(j)>>bigint(s)));
assert((b5.at(j)>>s) == (i5.at(j)>>bigint(s)));
assert((b5.at(j)>>s) == (b5.at(j)>>int(s)));
assert((b5.at(j)>>s) == (b5.at(j)>>long(s)));
assert((b5.at(j)>>s) == (b5.at(j)>>(unsigned int)(s)));
assert((b5.at(j)>>s) == (b5.at(j)>>(unsigned long)(s)));
assert((b5.at(j)>>s) == (b5.at(j)>>(unsigned long long)(s)));
}
}
static void test_addsub()
{
for (bigint j = 0;j < POOL;++j)
for (bigint k = 0;k < POOL;++k) {
assert(b0.at(j)+b0.at(k) == b0.at(j)+i0.at(k)); assert(b0.at(j)+b0.at(k) == i0.at(j)+b0.at(k)); assert(b0.at(j)+b0.at(k) == (long long) i0.at(j)+(long long) i0.at(k));
assert(b1.at(j)+b1.at(k) == b1.at(j)+i1.at(k)); assert(b1.at(j)+b1.at(k) == i1.at(j)+b1.at(k));
assert(b2.at(j)+b2.at(k) == b2.at(j)+i2.at(k)); assert(b2.at(j)+b2.at(k) == i2.at(j)+b2.at(k));
assert(b3.at(j)+b3.at(k) == b3.at(j)+i3.at(k)); assert(b3.at(j)+b3.at(k) == i3.at(j)+b3.at(k)); assert(b3.at(j)+b3.at(k) == (unsigned long long) i3.at(j)+(unsigned long long) i3.at(k));
assert(b4.at(j)+b4.at(k) == b4.at(j)+i4.at(k)); assert(b4.at(j)+b4.at(k) == i4.at(j)+b4.at(k));
assert(b5.at(j)+b5.at(k) == b5.at(j)+i5.at(k)); assert(b5.at(j)+b5.at(k) == i5.at(j)+b5.at(k));
assert(b0.at(j)-b0.at(k) == b0.at(j)-i0.at(k)); assert(b0.at(j)-b0.at(k) == i0.at(j)-b0.at(k)); assert(b0.at(j)-b0.at(k) == (long long) i0.at(j)-(long long) i0.at(k));
assert(b1.at(j)-b1.at(k) == b1.at(j)-i1.at(k)); assert(b1.at(j)-b1.at(k) == i1.at(j)-b1.at(k));
assert(b2.at(j)-b2.at(k) == b2.at(j)-i2.at(k)); assert(b2.at(j)-b2.at(k) == i2.at(j)-b2.at(k));
assert(b3.at(j)-b3.at(k) == b3.at(j)-i3.at(k)); assert(b3.at(j)-b3.at(k) == i3.at(j)-b3.at(k)); assert(b3.at(j)-b3.at(k) == (long long) (unsigned long long) i3.at(j)-(long long) (unsigned long long) i3.at(k));
assert(b4.at(j)-b4.at(k) == b4.at(j)-i4.at(k)); assert(b4.at(j)-b4.at(k) == i4.at(j)-b4.at(k));
assert(b5.at(j)-b5.at(k) == b5.at(j)-i5.at(k)); assert(b5.at(j)-b5.at(k) == i5.at(j)-b5.at(k));
}
}
static void test_muldiv()
{
for (bigint j = 0;j < POOL;++j)
for (bigint k = 0;k < POOL;++k) {
assert(b0.at(j)*b0.at(k) == b0.at(j)*i0.at(k)); assert(b0.at(j)*b0.at(k) == i0.at(j)*b0.at(k)); assert(b0.at(j)*b0.at(k) == (long long) i0.at(j)*(long long) i0.at(k));
assert(b1.at(j)*b1.at(k) == b1.at(j)*i1.at(k)); assert(b1.at(j)*b1.at(k) == i1.at(j)*b1.at(k));
assert(b2.at(j)*b2.at(k) == b2.at(j)*i2.at(k)); assert(b2.at(j)*b2.at(k) == i2.at(j)*b2.at(k));
assert(b3.at(j)*b3.at(k) == b3.at(j)*i3.at(k)); assert(b3.at(j)*b3.at(k) == i3.at(j)*b3.at(k)); assert(b3.at(j)*b3.at(k) == (unsigned long long) i3.at(j)*(unsigned long long) i3.at(k));
assert(b4.at(j)*b4.at(k) == b4.at(j)*i4.at(k)); assert(b4.at(j)*b4.at(k) == i4.at(j)*b4.at(k));
assert(b5.at(j)*b5.at(k) == b5.at(j)*i5.at(k)); assert(b5.at(j)*b5.at(k) == i5.at(j)*b5.at(k));
if (i0.at(k) > 0 && i0.at(j) > 0) { assert(b0.at(j)/b0.at(k) == b0.at(j)/i0.at(k)); assert(b0.at(j)/b0.at(k) == i0.at(j)/b0.at(k)); assert(b0.at(j)/b0.at(k) == ((long long) i0.at(j))/(long long) i0.at(k)); }
if (i1.at(k) > 0 && i1.at(j) > 0) { assert(b1.at(j)/b1.at(k) == b1.at(j)/i1.at(k)); assert(b1.at(j)/b1.at(k) == i1.at(j)/b1.at(k)); }
if (i2.at(k) > 0 && i2.at(j) > 0) { assert(b2.at(j)/b2.at(k) == b2.at(j)/i2.at(k)); assert(b2.at(j)/b2.at(k) == i2.at(j)/b2.at(k)); }
if (i3.at(k) > 0 && i3.at(j) > 0) { assert(b3.at(j)/b3.at(k) == b3.at(j)/i3.at(k)); assert(b3.at(j)/b3.at(k) == i3.at(j)/b3.at(k)); assert(b3.at(j)/b3.at(k) == ((unsigned long long) i3.at(j))/(unsigned long long) i3.at(k)); }
if (i4.at(k) > 0 && i4.at(j) > 0) { assert(b4.at(j)/b4.at(k) == b4.at(j)/i4.at(k)); assert(b4.at(j)/b4.at(k) == i4.at(j)/b4.at(k)); }
if (i5.at(k) > 0 && i5.at(j) > 0) { assert(b5.at(j)/b5.at(k) == b5.at(j)/i5.at(k)); assert(b5.at(j)/b5.at(k) == i5.at(j)/b5.at(k)); }
if (i0.at(k) > 0 && i0.at(j) > 0) { assert(b0.at(j)%b0.at(k) == b0.at(j)%i0.at(k)); assert(b0.at(j)%b0.at(k) == i0.at(j)%b0.at(k)); assert(b0.at(j)%b0.at(k) == ((long long) i0.at(j))%(long long) i0.at(k)); }
if (i1.at(k) > 0 && i1.at(j) > 0) { assert(b1.at(j)%b1.at(k) == b1.at(j)%i1.at(k)); assert(b1.at(j)%b1.at(k) == i1.at(j)%b1.at(k)); }
if (i2.at(k) > 0 && i2.at(j) > 0) { assert(b2.at(j)%b2.at(k) == b2.at(j)%i2.at(k)); assert(b2.at(j)%b2.at(k) == i2.at(j)%b2.at(k)); }
if (i3.at(k) > 0 && i3.at(j) > 0) { assert(b3.at(j)%b3.at(k) == b3.at(j)%i3.at(k)); assert(b3.at(j)%b3.at(k) == i3.at(j)%b3.at(k)); assert(b3.at(j)%b3.at(k) == ((unsigned long long) i3.at(j))%(unsigned long long) i3.at(k)); }
if (i4.at(k) > 0 && i4.at(j) > 0) { assert(b4.at(j)%b4.at(k) == b4.at(j)%i4.at(k)); assert(b4.at(j)%b4.at(k) == i4.at(j)%b4.at(k)); }
if (i5.at(k) > 0 && i5.at(j) > 0) { assert(b5.at(j)%b5.at(k) == b5.at(j)%i5.at(k)); assert(b5.at(j)%b5.at(k) == i5.at(j)%b5.at(k)); }
}
}
static void test_equality()
{
for (bigint j = 0;j < POOL;++j) {
assert(i0.at(j) == (long long) b0.at(j));
assert(i1.at(j) == (long long) b1.at(j));
assert(i2.at(j) == (long long) b2.at(j));
assert(i3.at(j) == (unsigned long long) b3.at(j));
assert(i4.at(j) == (unsigned long long) b4.at(j));
assert(i5.at(j) == (unsigned long long) b5.at(j));
assert(i0.at(j) == b0.at(j));
assert(b0.at(j) == i0.at(j));
assert(i1.at(j) == b1.at(j));
assert(b1.at(j) == i1.at(j));
assert(i2.at(j) == b2.at(j));
assert(b2.at(j) == i2.at(j));
assert(i3.at(j) == b3.at(j));
assert(b3.at(j) == i3.at(j));
assert(i4.at(j) == b4.at(j));
assert(b4.at(j) == i4.at(j));
assert(i5.at(j) == b5.at(j));
assert(b5.at(j) == i5.at(j));
assert(!(i0.at(j) != b0.at(j)));
assert(!(b0.at(j) != i0.at(j)));
assert(!(i1.at(j) != b1.at(j)));
assert(!(b1.at(j) != i1.at(j)));
assert(!(i2.at(j) != b2.at(j)));
assert(!(b2.at(j) != i2.at(j)));
assert(!(i3.at(j) != b3.at(j)));
assert(!(b3.at(j) != i3.at(j)));
assert(!(i4.at(j) != b4.at(j)));
assert(!(b4.at(j) != i4.at(j)));
assert(!(i5.at(j) != b5.at(j)));
assert(!(b5.at(j) != i5.at(j)));
}
}
static void test_ltgt()
{
for (bigint j = 0;j < POOL;++j) {
assert(!(i0.at(j) < b0.at(j)));
assert(!(b0.at(j) < i0.at(j)));
assert(!(i1.at(j) < b1.at(j)));
assert(!(b1.at(j) < i1.at(j)));
assert(!(i2.at(j) < b2.at(j)));
assert(!(b2.at(j) < i2.at(j)));
assert(!(i3.at(j) < b3.at(j)));
assert(!(b3.at(j) < i3.at(j)));
assert(!(i4.at(j) < b4.at(j)));
assert(!(b4.at(j) < i4.at(j)));
assert(!(i5.at(j) < b5.at(j)));
assert(!(b5.at(j) < i5.at(j)));
assert(i0.at(j) <= b0.at(j));
assert(b0.at(j) <= i0.at(j));
assert(i1.at(j) <= b1.at(j));
assert(b1.at(j) <= i1.at(j));
assert(i2.at(j) <= b2.at(j));
assert(b2.at(j) <= i2.at(j));
assert(i3.at(j) <= b3.at(j));
assert(b3.at(j) <= i3.at(j));
assert(i4.at(j) <= b4.at(j));
assert(b4.at(j) <= i4.at(j));
assert(i5.at(j) <= b5.at(j));
assert(b5.at(j) <= i5.at(j));
assert(!(i0.at(j) > b0.at(j)));
assert(!(b0.at(j) > i0.at(j)));
assert(!(i1.at(j) > b1.at(j)));
assert(!(b1.at(j) > i1.at(j)));
assert(!(i2.at(j) > b2.at(j)));
assert(!(b2.at(j) > i2.at(j)));
assert(!(i3.at(j) > b3.at(j)));
assert(!(b3.at(j) > i3.at(j)));
assert(!(i4.at(j) > b4.at(j)));
assert(!(b4.at(j) > i4.at(j)));
assert(!(i5.at(j) > b5.at(j)));
assert(!(b5.at(j) > i5.at(j)));
assert(i0.at(j) >= b0.at(j));
assert(b0.at(j) >= i0.at(j));
assert(i1.at(j) >= b1.at(j));
assert(b1.at(j) >= i1.at(j));
assert(i2.at(j) >= b2.at(j));
assert(b2.at(j) >= i2.at(j));
assert(i3.at(j) >= b3.at(j));
assert(b3.at(j) >= i3.at(j));
assert(i4.at(j) >= b4.at(j));
assert(b4.at(j) >= i4.at(j));
assert(i5.at(j) >= b5.at(j));
assert(b5.at(j) >= i5.at(j));
}
}
static void test_morecomparisons()
{
bigint x;
for (bigint j = 0;j < POOL;++j) {
x = b0.at(j); ++x; assert(x == b0.at(j)+1); assert(x == 1+b0.at(j));
assert(x > b0.at(j)); assert(b0.at(j) < x); assert(x >= b0.at(j)); assert(b0.at(j) <= x); assert(x != b0.at(j));
assert(!(x == b0.at(j))); assert(!(x < b0.at(j))); assert(!(b0.at(j) > x)); assert(!(x <= b0.at(j))); assert(!(b0.at(j) >= x));
assert(x > i0.at(j)); assert(i0.at(j) < x); assert(x >= i0.at(j)); assert(i0.at(j) <= x); assert(x != i0.at(j));
assert(!(x == i0.at(j))); assert(!(x < i0.at(j))); assert(!(i0.at(j) > x)); assert(!(x <= i0.at(j))); assert(!(i0.at(j) >= x));
--x; assert(x == b0.at(j));
x = b1.at(j); ++x; assert(x == b1.at(j)+1); assert(x == 1+b1.at(j));
assert(x > b1.at(j)); assert(b1.at(j) < x); assert(x >= b1.at(j)); assert(b1.at(j) <= x); assert(x != b1.at(j));
assert(!(x == b1.at(j))); assert(!(x < b1.at(j))); assert(!(b1.at(j) > x)); assert(!(x <= b1.at(j))); assert(!(b1.at(j) >= x));
assert(x > i1.at(j)); assert(i1.at(j) < x); assert(x >= i1.at(j)); assert(i1.at(j) <= x); assert(x != i1.at(j));
assert(!(x == i1.at(j))); assert(!(x < i1.at(j))); assert(!(i1.at(j) > x)); assert(!(x <= i1.at(j))); assert(!(i1.at(j) >= x));
--x; assert(x == b1.at(j));
x = b2.at(j); ++x; assert(x == b2.at(j)+1); assert(x == 1+b2.at(j));
assert(x > b2.at(j)); assert(b2.at(j) < x); assert(x >= b2.at(j)); assert(b2.at(j) <= x); assert(x != b2.at(j));
assert(!(x == b2.at(j))); assert(!(x < b2.at(j))); assert(!(b2.at(j) > x)); assert(!(x <= b2.at(j))); assert(!(b2.at(j) >= x));
assert(x > i2.at(j)); assert(i2.at(j) < x); assert(x >= i2.at(j)); assert(i2.at(j) <= x); assert(x != i2.at(j));
assert(!(x == i2.at(j))); assert(!(x < i2.at(j))); assert(!(i2.at(j) > x)); assert(!(x <= i2.at(j))); assert(!(i2.at(j) >= x));
--x; assert(x == b2.at(j));
x = b3.at(j); ++x; assert(x == b3.at(j)+1); assert(x == 1+b3.at(j));
assert(x > b3.at(j)); assert(b3.at(j) < x); assert(x >= b3.at(j)); assert(b3.at(j) <= x); assert(x != b3.at(j));
assert(!(x == b3.at(j))); assert(!(x < b3.at(j))); assert(!(b3.at(j) > x)); assert(!(x <= b3.at(j))); assert(!(b3.at(j) >= x));
assert(x > i3.at(j)); assert(i3.at(j) < x); assert(x >= i3.at(j)); assert(i3.at(j) <= x); assert(x != i3.at(j));
assert(!(x == i3.at(j))); assert(!(x < i3.at(j))); assert(!(i3.at(j) > x)); assert(!(x <= i3.at(j))); assert(!(i3.at(j) >= x));
--x; assert(x == b3.at(j));
x = b4.at(j); ++x; assert(x == b4.at(j)+1); assert(x == 1+b4.at(j));
assert(x > b4.at(j)); assert(b4.at(j) < x); assert(x >= b4.at(j)); assert(b4.at(j) <= x); assert(x != b4.at(j));
assert(!(x == b4.at(j))); assert(!(x < b4.at(j))); assert(!(b4.at(j) > x)); assert(!(x <= b4.at(j))); assert(!(b4.at(j) >= x));
assert(x > i4.at(j)); assert(i4.at(j) < x); assert(x >= i4.at(j)); assert(i4.at(j) <= x); assert(x != i4.at(j));
assert(!(x == i4.at(j))); assert(!(x < i4.at(j))); assert(!(i4.at(j) > x)); assert(!(x <= i4.at(j))); assert(!(i4.at(j) >= x));
--x; assert(x == b4.at(j));
x = b5.at(j); ++x; assert(x == b5.at(j)+1); assert(x == 1+b5.at(j));
assert(x > b5.at(j)); assert(b5.at(j) < x); assert(x >= b5.at(j)); assert(b5.at(j) <= x); assert(x != b5.at(j));
assert(!(x == b5.at(j))); assert(!(x < b5.at(j))); assert(!(b5.at(j) > x)); assert(!(x <= b5.at(j))); assert(!(b5.at(j) >= x));
assert(x > i5.at(j)); assert(i5.at(j) < x); assert(x >= i5.at(j)); assert(i5.at(j) <= x); assert(x != i5.at(j));
assert(!(x == i5.at(j))); assert(!(x < i5.at(j))); assert(!(i5.at(j) > x)); assert(!(x <= i5.at(j))); assert(!(i5.at(j) >= x));
--x; assert(x == b5.at(j));
}
}
static void test_bit()
{
bigint x;
for (bigint j = 0;j < POOL;++j) {
x = b0.at(j); for (long long e = 0;e < 8*sizeof(int);++e) assert(x.bit(e) == (1&(i0.at(j)>>e)));
x = b1.at(j); for (long long e = 0;e < 8*sizeof(long);++e) assert(x.bit(e) == (1&(i1.at(j)>>e)));
x = b2.at(j); for (long long e = 0;e < 8*sizeof(long long);++e) assert(x.bit(e) == (1&(i2.at(j)>>e)));
x = b3.at(j); for (long long e = 0;e < 8*sizeof(int);++e) assert(x.bit(e) == (1&(i3.at(j)>>e)));
x = b4.at(j); for (long long e = 0;e < 8*sizeof(long);++e) assert(x.bit(e) == (1&(i4.at(j)>>e)));
x = b5.at(j); for (long long e = 0;e < 8*sizeof(long long);++e) assert(x.bit(e) == (1&(i5.at(j)>>e)));
}
}
int main()
{
test_misc();
init_arrays();
print_minmax();
test_leftshift();
test_rightshift();
test_equality();
test_ltgt();
test_morecomparisons();
test_addsub();
test_muldiv();
test_bit();
return 0;
}