io.cpp
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2019 Joel Holdsworth <joel.holdsworth@vcatechnology.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #include <sstream>
11 
12 #include "main.h"
13 
14 template<typename Scalar>
16 {
17  static void run()
18  {
19  const Array<Scalar,1,1> array(123);
20  std::ostringstream ss;
21  ss << array;
22  VERIFY(ss.str() == "123");
23 
25  };
26 };
27 
28 template<>
29 struct check_ostream_impl<bool>
30 {
31  static void run()
32  {
33  const Array<bool,1,2> array(1, 0);
34  std::ostringstream ss;
35  ss << array;
36  VERIFY(ss.str() == "1 0");
37  };
38 };
39 
40 template<typename Scalar>
41 struct check_ostream_impl< std::complex<Scalar> >
42 {
43  static void run()
44  {
45  const Array<std::complex<Scalar>,1,1> array(std::complex<Scalar>(12, 34));
46  std::ostringstream ss;
47  ss << array;
48  VERIFY(ss.str() == "(12,34)");
49  };
50 };
51 
52 template<typename Scalar>
53 static void check_ostream()
54 {
56 }
57 
59 {
60  CALL_SUBTEST(check_ostream<bool>());
61  CALL_SUBTEST(check_ostream<float>());
62  CALL_SUBTEST(check_ostream<double>());
63  CALL_SUBTEST(check_ostream<Eigen::numext::int8_t>());
64  CALL_SUBTEST(check_ostream<Eigen::numext::uint8_t>());
65  CALL_SUBTEST(check_ostream<Eigen::numext::int16_t>());
66  CALL_SUBTEST(check_ostream<Eigen::numext::uint16_t>());
67  CALL_SUBTEST(check_ostream<Eigen::numext::int32_t>());
68  CALL_SUBTEST(check_ostream<Eigen::numext::uint32_t>());
69  CALL_SUBTEST(check_ostream<Eigen::numext::int64_t>());
70  CALL_SUBTEST(check_ostream<Eigen::numext::uint64_t>());
71 }
int array[24]
Definition: BFloat16.h:88
static void run()
Definition: io.cpp:31
EIGEN_DECLARE_TEST(rand)
Definition: io.cpp:58
static void check_ostream()
Definition: io.cpp:53
static std::stringstream ss
Definition: testBTree.cpp:31
static void run()
Definition: io.cpp:17
#define CALL_SUBTEST(FUNC)
Definition: main.h:399
#define VERIFY(a)
Definition: main.h:380
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:45


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:25