mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
synced 2025-12-19 11:57:06 +00:00
an attempt to reproduce GH #491
This commit is contained in:
@@ -76,6 +76,44 @@ public:
|
||||
|
||||
private:
|
||||
std::string getTestFilesPath(const std::string& type);
|
||||
|
||||
template <typename T>
|
||||
void testNumber(T number)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "{ \"test\" : " << number << " }";
|
||||
std::string json = os.str();
|
||||
Parser parser;
|
||||
Var result;
|
||||
|
||||
try
|
||||
{
|
||||
result = parser.parse(json);
|
||||
}
|
||||
catch (JSONException& jsone)
|
||||
{
|
||||
std::cout << jsone.message() << std::endl;
|
||||
assert(false);
|
||||
}
|
||||
|
||||
assert(result.type() == typeid(Object::Ptr));
|
||||
|
||||
Object::Ptr object = result.extract<Object::Ptr>();
|
||||
Var test = object->get("test");
|
||||
assert(test.isNumeric());
|
||||
T value = test;
|
||||
assert(value == number);
|
||||
|
||||
DynamicStruct ds = *object;
|
||||
assert(!ds["test"].isEmpty());
|
||||
assert(ds["test"].isNumeric());
|
||||
assert(ds["test"] == number);
|
||||
|
||||
const DynamicStruct& rds = *object;
|
||||
assert(!rds["test"].isEmpty());
|
||||
assert(rds["test"].isNumeric());
|
||||
assert(rds["test"] == number);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user