From 1b6e0395e6d9b3330619df41d3f36e1d667cab54 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Mon, 25 Nov 2019 15:23:55 +0000 Subject: Added io test --- test/io.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 test/io.cpp (limited to 'test/io.cpp') diff --git a/test/io.cpp b/test/io.cpp new file mode 100644 index 000000000..aa14e76e9 --- /dev/null +++ b/test/io.cpp @@ -0,0 +1,71 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2019 Joel Holdsworth +// +// This Source Code Form is subject to the terms of the Mozilla +// Public License v. 2.0. If a copy of the MPL was not distributed +// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include "main.h" + +template +struct check_ostream_impl +{ + static void run() + { + const Array array(123); + std::ostringstream ss; + ss << array; + VERIFY(ss.str() == "123"); + + check_ostream_impl< std::complex >::run(); + }; +}; + +template<> +struct check_ostream_impl +{ + static void run() + { + const Array array(1, 0); + std::ostringstream ss; + ss << array; + VERIFY(ss.str() == "1 0"); + }; +}; + +template +struct check_ostream_impl< std::complex > +{ + static void run() + { + const Array,1,1> array(std::complex(12, 34)); + std::ostringstream ss; + ss << array; + VERIFY(ss.str() == "(12,34)"); + }; +}; + +template +static void check_ostream() +{ + check_ostream_impl::run(); +} + +EIGEN_DECLARE_TEST(rand) +{ + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); + CALL_SUBTEST(check_ostream()); +} -- cgit v1.2.3