-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjson_test_fixture.cpp
More file actions
50 lines (36 loc) · 1.24 KB
/
json_test_fixture.cpp
File metadata and controls
50 lines (36 loc) · 1.24 KB
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
#include "json/test/fixtures/json_test_fixture.hpp"
#include "json/api/json_object.hpp"
#include "json/ih/json_accessor_impl.hpp"
#include "exception/ih/exc_internal_error.hpp"
//------------------------------------------------------------------------------
namespace json::test
{
//------------------------------------------------------------------------------
JsonFixture::JsonFixture() = default;
JsonFixture::~JsonFixture() = default;
//------------------------------------------------------------------------------
void JsonFixture::createJsonFile( std::string_view _text )
{
m_text << _text;
}
//------------------------------------------------------------------------------
const JsonObject & JsonFixture::loadJson()
{
JsonAccessor & accessor = ensureJsonAccessor();
auto newJson = accessor.createJson( m_text );
INTERNAL_CHECK_WARRING( newJson );
m_json.swap( newJson );
INTERNAL_CHECK_ERROR( m_json );
return *m_json;
}
//------------------------------------------------------------------------------
JsonAccessor & JsonFixture::ensureJsonAccessor()
{
if( !m_accessor )
{
m_accessor = std::make_unique< JsonAccesorImpl >();
}
return *m_accessor;
}
//------------------------------------------------------------------------------
}