summaryrefslogtreecommitdiff
path: root/vendor/bandit/specs/fakes/logging_fake.h
blob: ac1d3dd0459ea0d801113b0f20cfea74f2910b12 (plain)
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
#ifndef BANDIT_SPECS_LOGGING_FAKE_H
#define BANDIT_SPECS_LOGGING_FAKE_H
#include <sstream>

namespace bandit { namespace specs {

  struct logging_fake
  {
    std::ostream& log()
    {
      return logstm_;
    }

    std::string strip_newline(const char* val)
    {
      std::string no_newline = val;
      std::transform(no_newline.begin(), no_newline.end(), no_newline.begin(), [](const char& c) {
          return (c == '\n' || c == '\r') ? ' ' : c;
      });
      return no_newline;
    }

    std::string call_log()
    {
      return logstm_.str();
    }

    private:
    std::stringstream logstm_;
  };
}}
#endif