rippled
test
json
TestOutputSuite.h
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#ifndef RIPPLE_RPC_TESTOUTPUTSUITE_H_INCLUDED
21
#define RIPPLE_RPC_TESTOUTPUTSUITE_H_INCLUDED
22
23
#include <ripple/json/Output.h>
24
#include <ripple/json/Writer.h>
25
#include <test/jtx/TestSuite.h>
26
27
namespace
ripple
{
28
namespace
test {
29
30
class
TestOutputSuite
:
public
TestSuite
31
{
32
protected
:
33
std::string
output_
;
34
std::unique_ptr<Json::Writer>
writer_
;
35
36
void
37
setup
(
std::string
const
& testName)
38
{
39
testcase(testName);
40
output_
.
clear
();
41
writer_
= std::make_unique<Json::Writer>(
Json::stringOutput
(
output_
));
42
}
43
44
// Test the result and report values.
45
void
46
expectResult
(
std::string
const
& expected,
std::string
const
& message =
""
)
47
{
48
writer_
.
reset
();
49
50
expectEquals
(
output_
, expected, message);
51
}
52
};
53
54
}
// namespace test
55
}
// namespace ripple
56
57
#endif
ripple::test::TestOutputSuite::setup
void setup(std::string const &testName)
Definition:
TestOutputSuite.h:37
std::string
STL class.
ripple::TestSuite::expectEquals
bool expectEquals(S actual, T expected, std::string const &message="")
Definition:
TestSuite.h:33
std::unique_ptr::reset
T reset(T... args)
std::string::clear
T clear(T... args)
ripple::test::TestOutputSuite
Definition:
TestOutputSuite.h:30
ripple::test::TestOutputSuite::output_
std::string output_
Definition:
TestOutputSuite.h:33
ripple::test::TestOutputSuite::writer_
std::unique_ptr< Json::Writer > writer_
Definition:
TestOutputSuite.h:34
ripple::TestSuite
Definition:
TestSuite.h:28
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::test::TestOutputSuite::expectResult
void expectResult(std::string const &expected, std::string const &message="")
Definition:
TestOutputSuite.h:46
Json::stringOutput
Output stringOutput(std::string &s)
Definition:
json/Output.h:33
std::unique_ptr< Json::Writer >
Generated by
1.8.17