Macaulay2 Engine
Loading...
Searching...
No Matches
ARingQQFlintTest.cpp
Go to the documentation of this file.
1// Copyright 2012-2013 Michael E. Stillman
2
31
32#include <cstdio>
33#include <string>
34#include <iostream>
35#include <sstream>
36#include <memory>
37#include <gtest/gtest.h>
38#include <mpfr.h>
39
40#include "aring-qq-flint.hpp"
41
42#include "ARingTest.hpp"
43
45
46template <>
48 int index,
50{
51 if (index < 50)
52 R.set_from_long(result, index - 25);
53 else
54 {
55 R.random(result);
56 }
57}
58
59TEST(ARingQQFlint, create)
60{
62
64 buffer o;
65
67 R.init(a);
68 gen.nextElement(a);
69
70 EXPECT_EQ(ringName(R), "QQFlint");
71 EXPECT_EQ(R.cardinality(), static_cast<size_t>(-1));
72 EXPECT_EQ(R.characteristic(), 0);
73 R.clear(a);
74}
75
76TEST(ARingQQFlint, display)
77{
79
81 buffer o;
82
84 R.init(a);
85 R.init(b);
86 gen.nextElement(a);
87 gen.nextElement(b);
88 R.divide(a, a, b);
89 R.elem_text_out(o, a, true, false, false);
90 EXPECT_TRUE(strcmp(o.str(), "24/23") == 0);
91 std::cout << "a = ." << o.str() << "." << std::endl;
92
93 EXPECT_EQ(ringName(R), "QQFlint");
94 EXPECT_EQ(R.cardinality(), static_cast<size_t>(-1));
95 EXPECT_EQ(R.characteristic(), 0);
96 R.clear(a);
97}
98
99TEST(ARingQQFlint, arithmetic)
100{
102
103 testCoercions(R);
105 testAdd(R, ntrials);
110 // testPower(R, ntrials); // this test can't work, as it expects a finite
111 // field
113}
114
115// Local Variables:
116// compile-command: "make -C $M2BUILDDIR/Macaulay2/e/unit-tests check "
117// indent-tabs-mode: nil
118// End:
void getElement< M2::ARingQQFlint >(const M2::ARingQQFlint &R, int index, M2::ARingQQFlint::ElementType &result)
TEST(ARingQQFlint, create)
gmp_ZZ getRandomInteger()
void testAdd(const T &R, int ntrials)
void testNegate(const T &R, int ntrials)
void testReciprocal(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.
M2::ARingQQFlint — rationals backed by FLINT's fmpq with small-value inlining.
void nextElement(typename RingType::ElementType &result)
Definition ARingTest.hpp:56
void init(ElementType &result) const
void divide(ElementType &result, const ElementType &a, const ElementType &b) const
test doc
static void clear(ElementType &result)
void elem_text_out(buffer &o, const ElementType &a, bool p_one=true, bool p_plus=false, bool p_parens=false) const
size_t cardinality() const
void random(ElementType &result) const
size_t characteristic() const
void set_from_long(ElementType &result, long a) const
wrapper for the flint fmpq_t integer representation
char * str()
Definition buffer.hpp:72
void testDivide()
VALGRIND_MAKE_MEM_DEFINED & result(result)
mpz_srcptr gmp_ZZ
Definition m2-types.h:141