mirror of https://github.com/CGAL/cgal
67 lines
1.8 KiB
C++
67 lines
1.8 KiB
C++
// Author(s) : Michael Hemmer <mhemmer@uni-mainz.de>
|
|
|
|
|
|
|
|
/*! \file CGAL/Residue.C
|
|
test for number type modul
|
|
*/
|
|
|
|
#include <CGAL/basic.h>
|
|
#include <cassert>
|
|
#include <CGAL/Modular_traits.h>
|
|
#include <CGAL/Sqrt_extension.h>
|
|
|
|
#ifdef CGAL_USE_LEDA
|
|
#include <CGAL/leda_integer.h>
|
|
#include <CGAL/leda_rational.h>
|
|
#endif // CGAL_USE_LEDA
|
|
#ifdef CGAL_USE_CORE
|
|
#include <CGAL/CORE_BigInt.h>
|
|
#include <CGAL/CORE_BigRat.h>
|
|
#endif // CGAL_USE_CORE
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <boost/type_traits.hpp>
|
|
|
|
|
|
template <class TESTT>
|
|
void test_modular_traits(){
|
|
|
|
typedef CGAL::Residue Residue;
|
|
typedef CGAL::Modular_traits<TESTT> MT;
|
|
typedef typename MT::Residue_type Residue_type;
|
|
typedef typename MT::Modular_image Modular_image;
|
|
typedef typename MT::Is_modularizable Is_modularizable;
|
|
typedef typename MT::NT NT;
|
|
|
|
assert(
|
|
!(::boost::is_same<CGAL::Null_functor,Modular_image>::value));
|
|
assert(
|
|
(::boost::is_same<CGAL::Tag_true,Is_modularizable>::value));
|
|
assert(
|
|
(::boost::is_same<TESTT,NT>::value));
|
|
|
|
Residue::set_current_prime(7);
|
|
Modular_image modular_image;
|
|
assert(modular_image(TESTT(21)) == Residue_type(0));
|
|
assert(modular_image(TESTT(22)) == Residue_type(1));
|
|
assert(modular_image(TESTT(777777722)) == Residue_type(1));
|
|
}
|
|
|
|
int main()
|
|
{
|
|
test_modular_traits<int>();
|
|
#ifdef CGAL_USE_LEDA
|
|
test_modular_traits<leda::integer>();
|
|
test_modular_traits<leda::rational>();
|
|
test_modular_traits<CGAL::Sqrt_extension< leda::integer, leda::integer > >();
|
|
#endif
|
|
#ifdef CGAL_USE_CORE
|
|
test_modular_traits<CORE::BigInt>();
|
|
test_modular_traits<CORE::BigRat>();
|
|
test_modular_traits<CGAL::Sqrt_extension< CORE::BigInt, CORE::BigInt > >();
|
|
#endif
|
|
|
|
}
|