Add files
This commit is contained in:
92
core/test/generating/double.cpp
Normal file
92
core/test/generating/double.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
//This file is part of Bertini 2.
|
||||
//
|
||||
//test/generating/double.cpp is free software: you can redistribute it and/or modify
|
||||
//it under the terms of the GNU General Public License as published by
|
||||
//the Free Software Foundation, either version 3 of the License, or
|
||||
//(at your option) any later version.
|
||||
//
|
||||
//test/generating/double.cpp is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//GNU General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU General Public License
|
||||
//along with test/generating/double.cpp. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// Copyright(C) 2015 - 2017 by Bertini2 Development Team
|
||||
//
|
||||
// See <http://www.gnu.org/licenses/> for a copy of the license,
|
||||
// as well as COPYING. Bertini2 is provided with permitted
|
||||
// additional terms in the b2/licenses/ directory.
|
||||
|
||||
/**
|
||||
\file test/generating/double.cpp Tests the generating of text from double's.
|
||||
*/
|
||||
|
||||
|
||||
#include "bertini2/io/generators.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(double_generation)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(zero)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
double z(0);
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
BOOST_CHECK_EQUAL(std::stod(result),z);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(one)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
double z(1);
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
BOOST_CHECK_EQUAL(std::stod(result),z);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(sqrt_2)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
double z = sqrt(2);
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
BOOST_CHECK_EQUAL(std::stod(result),z);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(check_135_477005)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
double z = 135.477005;
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
BOOST_CHECK_EQUAL(std::stod(result),z);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
43
core/test/generating/generating_test.cpp
Normal file
43
core/test/generating/generating_test.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
//This file is part of Bertini 2.
|
||||
//
|
||||
//generating_test.cpp is free software: you can redistribute it and/or modify
|
||||
//it under the terms of the GNU General Public License as published by
|
||||
//the Free Software Foundation, either version 3 of the License, or
|
||||
//(at your option) any later version.
|
||||
//
|
||||
//generating_test.cpp is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//GNU General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU General Public License
|
||||
//along with generating_test.cpp. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// Copyright(C) 2015 - 2021 by Bertini2 Development Team
|
||||
//
|
||||
// See <http://www.gnu.org/licenses/> for a copy of the license,
|
||||
// as well as COPYING. Bertini2 is provided with permitted
|
||||
// additional terms in the b2/licenses/ directory.
|
||||
|
||||
// individual authors of this file include:
|
||||
// silviana amethyst, university of wisconsin eau claire
|
||||
//
|
||||
//
|
||||
// generating_test.cpp: main source file for the testing of generators for Bertini2
|
||||
|
||||
|
||||
|
||||
|
||||
#define BOOST_ALL_DYN_LINK 1
|
||||
|
||||
//this #define MUST appear before #include <boost/test/unit_test.hpp>
|
||||
#define BOOST_TEST_MODULE "Bertini 2 Generator Testing"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#define BERTINI_TEST_MODULE "generating"
|
||||
#include "test/utility/enable_logging.hpp"
|
||||
|
||||
|
||||
|
||||
// deliberately left blank. link other files with this one.
|
||||
|
||||
101
core/test/generating/mpfr_complex.cpp
Normal file
101
core/test/generating/mpfr_complex.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
//This file is part of Bertini 2.
|
||||
//
|
||||
//test/generating/mpfr_complex.cpp is free software: you can redistribute it and/or modify
|
||||
//it under the terms of the GNU General Public License as published by
|
||||
//the Free Software Foundation, either version 3 of the License, or
|
||||
//(at your option) any later version.
|
||||
//
|
||||
//test/generating/mpfr_complex.cpp is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//GNU General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU General Public License
|
||||
//along with test/generating/mpfr_complex.cpp. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// Copyright(C) 2015 - 2017 by Bertini2 Development Team
|
||||
//
|
||||
// See <http://www.gnu.org/licenses/> for a copy of the license,
|
||||
// as well as COPYING. Bertini2 is provided with permitted
|
||||
// additional terms in the b2/licenses/ directory.
|
||||
|
||||
/**
|
||||
\file test/generating/mpfr_complex.cpp Tests the generating of text from mpfr_complex's.
|
||||
*/
|
||||
|
||||
|
||||
#include "bertini2/io/generators.hpp"
|
||||
#include "bertini2/io/parsing/number_parsers.hpp"
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
||||
|
||||
using mpfr = bertini::mpfr_complex;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(mpfr_complex_generating)
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(round_trip)
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(zero)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
mpfr z(0,0);
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
mpfr rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
BOOST_CHECK_EQUAL(rt,z);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(one)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
mpfr z(1,-1);
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
mpfr rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
BOOST_CHECK_EQUAL(rt,z);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(two_comma_three)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
mpfr z = sqrt(mpfr(2,3));
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
bertini::DefaultPrecision(20);
|
||||
mpfr rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
|
||||
bertini::DefaultPrecision(30);
|
||||
|
||||
BOOST_CHECK(abs(rt-z) < 1e-30);
|
||||
BOOST_CHECK(rt.precision()>=30);
|
||||
|
||||
std::string result2;
|
||||
std::back_insert_iterator<std::string> sink2(result2);
|
||||
bertini::generators::Classic::generate(sink2, rt);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
112
core/test/generating/mpfr_float.cpp
Normal file
112
core/test/generating/mpfr_float.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
//This file is part of Bertini 2.
|
||||
//
|
||||
//test/generating/mpfr_float.cpp is free software: you can redistribute it and/or modify
|
||||
//it under the terms of the GNU General Public License as published by
|
||||
//the Free Software Foundation, either version 3 of the License, or
|
||||
//(at your option) any later version.
|
||||
//
|
||||
//test/generating/mpfr_float.cpp is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//GNU General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU General Public License
|
||||
//along with test/generating/mpfr_float.cpp. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// Copyright(C) 2015 - 2017 by Bertini2 Development Team
|
||||
//
|
||||
// See <http://www.gnu.org/licenses/> for a copy of the license,
|
||||
// as well as COPYING. Bertini2 is provided with permitted
|
||||
// additional terms in the b2/licenses/ directory.
|
||||
|
||||
/**
|
||||
\file test/generating/mpfr_float.cpp Tests the generating of text from mpfr_float's.
|
||||
*/
|
||||
|
||||
|
||||
#include "bertini2/io/generators.hpp"
|
||||
#include "bertini2/io/parsing/number_parsers.hpp"
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
||||
|
||||
using mpfr_float = bertini::mpfr_float;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(mpfr_float_generating)
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(round_trip)
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(zero)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
mpfr_float z(0);
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
mpfr_float rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
BOOST_CHECK_EQUAL(rt,z);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(one)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
mpfr_float z(1);
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
mpfr_float rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
BOOST_CHECK_EQUAL(rt,z);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(sqrt_2)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
mpfr_float z = sqrt(mpfr_float(2));
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
mpfr_float rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
BOOST_CHECK_EQUAL(rt,z);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(precision)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
mpfr_float z = sqrt(mpfr_float(2));
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
bertini::DefaultPrecision(20);
|
||||
|
||||
mpfr_float rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
|
||||
BOOST_CHECK_EQUAL(rt,z);
|
||||
BOOST_CHECK(rt.precision()>=30);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
102
core/test/generating/std_complex.cpp
Normal file
102
core/test/generating/std_complex.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
//This file is part of Bertini 2.
|
||||
//
|
||||
//test/generating/double.cpp is free software: you can redistribute it and/or modify
|
||||
//it under the terms of the GNU General Public License as published by
|
||||
//the Free Software Foundation, either version 3 of the License, or
|
||||
//(at your option) any later version.
|
||||
//
|
||||
//test/generating/double.cpp is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
//GNU General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU General Public License
|
||||
//along with test/generating/double.cpp. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// Copyright(C) 2015 - 2017 by Bertini2 Development Team
|
||||
//
|
||||
// See <http://www.gnu.org/licenses/> for a copy of the license,
|
||||
// as well as COPYING. Bertini2 is provided with permitted
|
||||
// additional terms in the b2/licenses/ directory.
|
||||
|
||||
/**
|
||||
\file test/generating/double.cpp Tests the generating of text from double's.
|
||||
*/
|
||||
|
||||
|
||||
#include "bertini2/io/generators.hpp"
|
||||
#include "bertini2/io/parsing/number_parsers.hpp"
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(complex_double_generation)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(zero)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
std::complex<double> z(0,0);
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
std::complex<double> rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
BOOST_CHECK_EQUAL(rt,z);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(one)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
std::complex<double> z(1,1);
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
std::complex<double> rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
BOOST_CHECK_EQUAL(rt,z);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(sqrt_2)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
std::complex<double> z(sqrt(2),sqrt(3));
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
std::complex<double> rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
BOOST_CHECK_EQUAL(rt,z);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(check_135_477005)
|
||||
{
|
||||
bertini::DefaultPrecision(30);
|
||||
std::complex<double> z(135.477005,135.477005234989817410289);
|
||||
|
||||
|
||||
std::string result;
|
||||
std::back_insert_iterator<std::string> sink(result);
|
||||
|
||||
BOOST_CHECK(bertini::generators::Classic::generate(sink, z));
|
||||
|
||||
std::complex<double> rt;
|
||||
BOOST_CHECK(bertini::parsing::classic::parse(result.begin(), result.end(), rt));
|
||||
BOOST_CHECK_EQUAL(rt,z);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user