Page MenuHomePhorge

qt-json-test.cpp
No OneTemporary

Size
813 B
Referenced Files
None
Subscribers
None

qt-json-test.cpp

/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include <kazv-defs.hpp>
#include <QtTest>
#include "qt-json.hpp"
class QtJsonTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testNumericConv();
};
static auto j = nlohmann::json::parse(R"({
"foo": 1
})");
static auto jFloat = nlohmann::json::parse(R"({
"foo": 1.0
})");
static auto jFloat2 = nlohmann::json::parse(R"({
"foo": 1.1
})");
void QtJsonTest::testNumericConv()
{
QJsonObject qj = j;
nlohmann::json j2 = qj;
QVERIFY(j2 == j);
qj = jFloat;
j2 = qj;
QVERIFY(j2 == j);
QVERIFY(j2 == jFloat);
qj = jFloat2;
j2 = qj;
QVERIFY(j2 == jFloat2);
}
QTEST_MAIN(QtJsonTest)
#include "qt-json-test.moc"

File Metadata

Mime Type
text/x-c
Expires
Sun, Nov 24, 3:45 PM (1 d, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39441
Default Alt Text
qt-json-test.cpp (813 B)

Event Timeline