blob: d79455c118435861952fd7131f7a70b48f8bef7b (
plain) (
blame)
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "util.h"
#include <vespa/storage/common/hostreporter/hostreporter.h>
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vdstestlib/cppunit/macros.h>
#include <vespa/vespalib/util/jsonstream.h>
#include <vespa/vespalib/stllike/asciistream.h>
namespace storage {
namespace util {
namespace {
using Object = vespalib::JsonStream::Object;
using End = vespalib::JsonStream::End;
using JsonFormat = vespalib::slime::JsonFormat;
using Memory = vespalib::Memory;
}
void
reporterToSlime(HostReporter &hostReporter, vespalib::Slime &slime) {
vespalib::asciistream json;
vespalib::JsonStream stream(json, true);
stream << Object();
hostReporter.report(stream);
stream << End();
std::string jsonData = json.str();
size_t parsedSize = JsonFormat::decode(Memory(jsonData), slime);
if (jsonData.size() != parsedSize) {
CPPUNIT_FAIL("Sizes of jsonData mismatched, probably not json:\n" + jsonData);
}
}
}
}
|