diff --git a/test/test_trailing_io_delim.cpp b/test/test_trailing_io_delim.cpp new file mode 100644 index 00000000..b7f7ebf8 --- /dev/null +++ b/test/test_trailing_io_delim.cpp @@ -0,0 +1,131 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2022 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). + +#ifdef TEST_CPP_INT +#include +#include +#include +#endif +#ifdef TEST_GMP +#include +#endif +#ifdef TEST_TOMMATH +#include +#endif +#ifdef TEST_FLOAT128 +#include +#include +#endif +#ifdef TEST_MPC +#include +#endif +#ifdef TEST_MPFI +#include +#endif + +#include +#include "test.hpp" + +template +void test_integer() +{ + std::istringstream iss("123#"); + T val; + iss >> val; + BOOST_CHECK_EQUAL(val, 123); +} + +template +void test_rational() +{ + { + std::istringstream iss("123#"); + T val; + iss >> val; + BOOST_CHECK_EQUAL(val, 123); + } + { + std::istringstream iss("123/23#"); + T val; + iss >> val; + BOOST_CHECK_EQUAL(val, T(123, 23)); + } +} + +template +void test_float() +{ + std::istringstream iss("123.0#"); + T val; + iss >> val; + BOOST_CHECK_EQUAL(val, 123.0); +} + +template +void test_complex() +{ + { + std::istringstream iss("123.0#"); + T val; + iss >> val; + BOOST_CHECK_EQUAL(val, 123.0); + } + { + std::istringstream iss("(123.0,23.0)#"); + T val; + iss >> val; + BOOST_CHECK_EQUAL(val, T(123.0, 23.0)); + } +} + +template +void test_interval() +{ + { + std::istringstream iss("123.0#"); + T val; + iss >> val; + BOOST_CHECK_EQUAL(val, 123.0); + } + { + std::istringstream iss("{123.0,124.0}#"); + T val; + iss >> val; + std::cout << val << std::endl; + BOOST_CHECK_EQUAL(val, T(123.0, 124.0)); + } +} + + +int main() +{ +#ifdef TEST_CPP_INT + test_integer(); + test_rational(); + test_float(); + test_complex(); +#endif +#ifdef TEST_GMP + test_integer(); + test_rational(); + test_float(); +#endif +#ifdef TEST_TOMMATH + test_integer(); + test_rational(); +#endif +#ifdef TEST_FLOAT128 + test_float(); + test_complex(); +#endif +#ifdef TEST_MPC + test_float(); + test_complex(); +#endif +#ifdef TEST_MPFI + test_interval(); +#endif + return 0; +}