Macaulay2 Engine
Loading...
Searching...
No Matches

◆ TEST() [11/14]

TEST ( RingZZ ,
random  )

Definition at line 72 of file RingZZTest.cpp.

73{
74 mpz_t b;
75 mpz_init(b);
76 mpz_t maxH;
77 mpz_init(maxH);
78 mpz_set_str(maxH, "100000000000", 10);
79 for (int i = 0; i <= 10; i++)
80 {
81 buffer o;
82 ring_elem a =
83 globalZZ->random(); // POOR DESIGN! Need to be able to choose size
84 gmp_ZZ a1 = rawRandomInteger(maxH); // This one is fine
85 a = globalZZ->from_int(a1);
86 globalZZ->elem_text_out(o, a);
87 // std::cout << o.str() << std::endl;
88 mpz_set_str(b, o.str(), 10);
89 ring_elem c = globalZZ->from_int(b);
90 EXPECT_TRUE(globalZZ->is_equal(a, c));
91 }
92 mpz_clear(maxH);
93 mpz_clear(b);
94}
static mpz_t maxH
char * str()
Definition buffer.hpp:72
RingZZ * globalZZ
Definition relem.cpp:13
mpz_srcptr gmp_ZZ
Definition m2-types.h:141
gmp_ZZ rawRandomInteger(gmp_ZZ maxN)
Definition random.cpp:66

References globalZZ, maxH, rawRandomInteger(), and buffer::str().