File: boost_test_print.h

package info (click to toggle)
tiledarray 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 9,568 kB
  • sloc: cpp: 53,449; javascript: 1,599; sh: 393; ansic: 226; python: 223; xml: 195; makefile: 36
file content (37 lines) | stat: -rw-r--r-- 805 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// Created by Eduard Valeyev on 7/14/20.
//

#ifndef TILEDARRAY_TESTS_BOOST_TEST_PRINT_H_
#define TILEDARRAY_TESTS_BOOST_TEST_PRINT_H_

#include <iosfwd>
#include <vector>

// teach Boost.Test how to print std::vector
// boost printing method
namespace boost {
namespace test_tools {
namespace tt_detail {
template <typename T>
struct print_log_value<std::vector<T> > {
  void operator()(std::ostream& s, const std::vector<T>& v) {
    const auto sz = v.size();

    if (sz == 0) {
      s << "[]";
    } else {
      s << "[ ";
      if (sz > 1)
        for (std::size_t i = 0; i != sz - 2; ++i) {
          s << v[i] << ", ";
        }
    }
    s << v.back() << " ]";
  }
};
}  // namespace tt_detail
}  // namespace test_tools
}  // namespace boost

#endif  // TILEDARRAY_TESTS_BOOST_TEST_PRINT_H_