Macaulay2 Engine
Loading...
Searching...
No Matches
ARingZZTest.cpp
Go to the documentation of this file.
1// Copyright 2012-2013 Michael E. Stillman
2
33
34#include <cstdio>
35#include <string>
36#include <iostream>
37#include <sstream>
38#include <memory>
39#include <gtest/gtest.h>
40#include <mpfr.h>
41
42#include "aring-zz-flint.hpp"
43#include "ARingTest.hpp"
44
46
47template <>
49 int index,
51{
52 if (index < 50)
53 R.set_from_long(result, index - 25);
54 else
55 {
57 R.set_from_mpz(result, a);
58 }
59}
60
61TEST(ARingZZ, create)
62{
64
66 buffer o;
67
69 R.init(a);
70 gen.nextElement(a);
71
72 EXPECT_EQ(ringName(R), "ZZFlint");
73 EXPECT_EQ(R.cardinality(), static_cast<size_t>(-1));
74 EXPECT_EQ(R.characteristic(), 0);
75 R.clear(a);
76}
77
78TEST(ARingZZ, arithmetic)
79{
81
84 testAdd(R, ntrials);
88 // testReciprocal(R, ntrials); // this test is not applicable, as this is not
89 // a field
90 // testPower(R, ntrials); // this test can't work, as it expects a finite
91 // field
93}
94
95// Local Variables:
96// compile-command: "make -C $M2BUILDDIR/Macaulay2/e/unit-tests check "
97// indent-tabs-mode: nil
98// End:
void testAdd(const T &R, int ntrials)
void testNegate(const T &R, int ntrials)
void testCoercions(const T &R)
void testAxioms(const T &R, int ntrials)
const int ntrials
Definition ARingTest.hpp:42
void testSubtract(const T &R, int ntrials)
void testMultiply(const T &R, int ntrials)
std::string ringName(const T &R)
Shared gtest harness for the ARing*Test.cpp suite.
TEST(ARingZZ, create)
void getElement< M2::ARingZZ >(const M2::ARingZZ &R, int index, M2::ARingZZ::ElementType &result)
gmp_ZZ getRandomInteger()
M2::ARingZZ — FLINT-backed arbitrary-precision integers with small-value inlining.
void nextElement(typename RingType::ElementType &result)
Definition ARingTest.hpp:56
size_t cardinality() const
size_t characteristic() const
void init(ElementType &result) const
void set_from_long(ElementType &result, long a) const
static void clear(ElementType &result)
void set_from_mpz(ElementType &result, mpz_srcptr a) const
wrapper for the flint fmpz_t integer representation
void testDivide()
VALGRIND_MAKE_MEM_DEFINED & result(result)
mpz_srcptr gmp_ZZ
Definition m2-types.h:141