summaryrefslogtreecommitdiffstats
path: root/src/bin/d2/tests/parser_unittest.h
blob: bcefcb788f9291c3a54a1330ff2dc64e624d0f1d (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
33
34
35
36
// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef PARSER_UNITTEST_H
#define PARSER_UNITTEST_H

#include <gtest/gtest.h>
#include <cc/data.h>
#include <d2/parser_context.h>

using namespace isc::data;
using namespace std;

namespace isc {
namespace d2 {
namespace test {

/// @brief Runs parser in JSON mode, useful for parser testing
///
/// @param in string to be parsed
/// @return ElementPtr structure representing parsed JSON
inline isc::data::ElementPtr
parseJSON(const std::string& in)
{
    isc::d2::D2ParserContext ctx;
    return (ctx.parseString(in, isc::d2::D2ParserContext::PARSER_JSON));
}

}
}
}

#endif // PARSER_UNITTEST_H