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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// *****************************************************************************
/*!
  \file      tests/unit/Base/TestPrintTaggedTupleDeep.cpp
  \copyright 2012-2015 J. Bakosi,
             2016-2018 Los Alamos National Security, LLC.,
             2019-2021 Triad National Security, LLC.,
             2022-2025 J. Bakosi
             All rights reserved. See the LICENSE file for details.
  \brief     Unit tests for TaggedTuple deep printer
*/
// *****************************************************************************

#include <sstream><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "NoWarning/tut.hpp"<--- Include file: "NoWarning/tut.hpp" not found.

#include "TUTConfig.hpp"<--- Include file: "TUTConfig.hpp" not found.
#include "PrintTaggedTupleDeep.hpp"

#ifndef DOXYGEN_GENERATING_OUTPUT

namespace tut {

//! All tests in group inherited from this base
struct PrintTaggedTupleDeep_common {
  // Tags
  DEFTAG( name );
  DEFTAG( age );
  DEFTAG( email );
  DEFTAG( tag1 );
  DEFTAG( tag2 );
  DEFTAG( tag3 );

  // Define a tk::TaggedTuple by inheriting from TaggedTuple
  struct Cmd : public tk::TaggedTuple< brigand::list<
                        name,  std::string,
                        age,   int,
                        email, std::string,
                        tag1,  tk::TaggedTuple< brigand::list <
                                  tag2, std::string,
                                  tag3, std::string > > > >
  {};

  // Constructor
  PrintTaggedTupleDeep_common() {
    cmd.get< name >() = "Bob";
    cmd.get< age >() = 32;
    cmd.get< email >() = "bob@google.com";
    auto& t1 = cmd.get< tag1 >();
    t1.get< tag2 >() = "string2";
    t1.get< tag3 >() = "string3";
  }

  Cmd cmd;
};

//! Test group shortcuts
using PrintTaggedTupleDeep_group =
  test_group< PrintTaggedTupleDeep_common, MAX_TESTS_IN_GROUP >;
using PrintTaggedTupleDeep_object = PrintTaggedTupleDeep_group::object;

//! Define test group
static PrintTaggedTupleDeep_group
  PrintTaggedTupleDeep( "Base/PrintTaggedTupleDeep" );

//! Test definitions for group

//! Test print() of TaggedTuple with depth/indentation
template<> template<>
void PrintTaggedTupleDeep_object::test< 1 >() {
  set_test_name( "print()" );

  std::stringstream s;
  tk::print( s, cmd );
  ensure_equals( "print()", s.str(),
R"({
  name = Bob
  age = 32
  email = bob@google.com
  tag1 = {
    tag2 = string2
    tag3 = string3
  }
}
)" );
}

} // tut::

#endif  // DOXYGEN_GENERATING_OUTPUT