Unit tests for ParamList to json.

This commit is contained in:
eelke 2017-12-09 19:39:37 +01:00
parent e9f5fff6d3
commit dec52a3829
5 changed files with 72 additions and 11 deletions

View file

@ -16,12 +16,16 @@ HEADERS += \
tst_PasswordManager.h
SOURCES += main.cpp \
tst_ExplainJsonParser.cpp
tst_ExplainJsonParser.cpp \
tst_ParamJson.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../core/release/ -lcore
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../core/debug/ -lcore
INCLUDEPATH += C:\prog\include C:\VSproj\boost_1_63_0
INCLUDEPATH += C:\prog\include \
C:\Prog\include\pgsql \
C:\VSproj\boost32\include\boost-1_65_1
INCLUDEPATH += $$PWD/../../../core
DEPENDPATH += $$PWD/../../../core
LIBS += c:\prog\lib\botand_imp.lib
@ -30,3 +34,16 @@ win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../c
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../core/debug/libcore.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../core/release/core.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../core/debug/core.lib
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../pgsql/release/ -lpgsql
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../pgsql/debug/ -lpgsql
else:unix:!macx: LIBS += -L$$OUT_PWD/../../../pgsql/ -lpgsql
INCLUDEPATH += $$PWD/../../../pgsql
DEPENDPATH += $$PWD/../../../pgsql
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../pgsql/release/libpgsql.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../pgsql/debug/libpgsql.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../pgsql/release/pgsql.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../../../pgsql/debug/pgsql.lib
else:unix:!macx: PRE_TARGETDEPS += $$OUT_PWD/../../../pgsql/libpgsql.a

View file

@ -0,0 +1,29 @@
#include <gtest/gtest.h>
#include <gmock/gmock-matchers.h>
#include "ParamListModel.h"
#include "ParamListJson.h"
using namespace testing;
TEST(ParamListToJson, test1)
{
t_ParamList params;
params.emplace_back("valuestr", "typestr");
Json::Value root = ParamListToJson(params); // will contains the root value after parsing.
ASSERT_TRUE(root.isArray());
ASSERT_EQ(root.size(), 1);
Json::Value e = root[0];
ASSERT_TRUE(e.isMember("type"));
ASSERT_TRUE(e.isMember("value"));
ASSERT_EQ(e["type"].asString(), "typestr");
ASSERT_EQ(e["value"].asString(), "valuestr");
// Json::Reader reader;
// bool parsingSuccessful = reader.parse(input, root);
// auto explain = ExplainRoot::createFromJson(root);
// ASSERT_TRUE(explain != nullptr);
}