Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F113176
qt-json-test.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
813 B
Referenced Files
None
Subscribers
None
qt-json-test.cpp
View Options
/*
* 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
Details
Attached
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)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment