1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-10-13 22:47:18 +02:00

Major plugin refactor and cleanup.

Switched to POCO library for unified platform/library interface.
Deprecated the external module API. It was creating more problems than solving.
Removed most built-in libraries in favor of system libraries for easier maintenance.
Cleaned and secured code with help from static analyzers.
This commit is contained in:
Sandu Liviu Catalin
2021-01-30 08:51:39 +02:00
parent e0e34b4030
commit 4a6bfc086c
6219 changed files with 1209835 additions and 454916 deletions

View File

@@ -0,0 +1,17 @@
//
// Driver.cpp
//
// Console-based test driver for Poco JSON.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "CppUnit/TestRunner.h"
#include "JSONTestSuite.h"
CppUnitMain(JSONTestSuite)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,133 @@
//
// JSONTest.h
//
// Definition of the JSONTest class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef JSONTest_INCLUDED
#define JSONTest_INCLUDED
#include "Poco/JSON/JSON.h"
#include "CppUnit/TestCase.h"
#include "Poco/JSON/Object.h"
#include "Poco/JSON/Parser.h"
#include "Poco/JSON/Query.h"
#include "Poco/JSON/JSONException.h"
#include "Poco/JSON/Stringifier.h"
#include "Poco/JSON/ParseHandler.h"
#include "Poco/JSON/PrintHandler.h"
#include "Poco/JSON/Template.h"
#include <sstream>
class JSONTest: public CppUnit::TestCase
{
public:
JSONTest(const std::string& name);
~JSONTest();
void testNullProperty();
void testTrueProperty();
void testFalseProperty();
void testNumberProperty();
void testUnsignedNumberProperty();
#if defined(POCO_HAVE_INT64)
void testNumber64Property();
void testUnsignedNumber64Property();
#endif
void testStringProperty();
void testEmptyObject();
void testEmptyPropertyName();
void testComplexObject();
void testDoubleProperty();
void testDouble2Property();
void testDouble3Property();
void testObjectProperty();
void testObjectArray();
void testArrayOfObjects();
void testEmptyArray();
void testNestedArray();
void testNullElement();
void testTrueElement();
void testFalseElement();
void testNumberElement();
void testStringElement();
void testEmptyObjectElement();
void testDoubleElement();
void testSetArrayElement();
void testOptValue();
void testQuery();
void testComment();
void testPrintHandler();
void testStringify();
void testStringifyPreserveOrder();
void testValidJanssonFiles();
void testInvalidJanssonFiles();
void testTemplate();
void testUnicode();
void testInvalidUnicodeJanssonFiles();
void testSmallBuffer();
void testEscape0();
void testNonEscapeUnicode();
void testEscapeUnicode();
void testCopy();
void testMove();
void setUp();
void tearDown();
static CppUnit::Test* suite();
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();
Poco::JSON::Parser parser;
Poco::Dynamic::Var result;
try
{
result = parser.parse(json);
}
catch (Poco::JSON::JSONException& jsone)
{
std::cout << jsone.message() << std::endl;
assertTrue (false);
}
assertTrue (result.type() == typeid(Poco::JSON::Object::Ptr));
Poco::JSON::Object::Ptr object = result.extract<Poco::JSON::Object::Ptr>();
Poco::Dynamic::Var test = object->get("test");
assertTrue (test.isNumeric());
T value = test;
assertTrue (value == number);
Poco::DynamicStruct ds = *object;
assertTrue (!ds["test"].isEmpty());
assertTrue (ds["test"].isNumeric());
assertTrue (ds["test"] == number);
const Poco::DynamicStruct& rds = *object;
assertTrue (!rds["test"].isEmpty());
assertTrue (rds["test"].isNumeric());
assertTrue (rds["test"] == number);
}
};
#endif // JSONTest_INCLUDED

View File

@@ -0,0 +1,22 @@
//
// JSONTestSuite.cpp
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "JSONTestSuite.h"
#include "JSONTest.h"
CppUnit::Test* JSONTestSuite::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("JSONTestSuite");
pSuite->addTest(JSONTest::suite());
return pSuite;
}

View File

@@ -0,0 +1,27 @@
//
// JSONTestSuite.h
//
// Definition of the JSONTestSuite class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef JSONTestSuite_INCLUDED
#define JSONTestSuite_INCLUDED
#include "CppUnit/TestSuite.h"
class JSONTestSuite
{
public:
static CppUnit::Test* suite();
};
#endif // JSONTestSuite_INCLUDED

View File

@@ -0,0 +1,30 @@
//
// WinCEDriver.cpp
//
// Console-based test driver for Windows CE.
//
// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "CppUnit/TestRunner.h"
#include "JSONTestSuite.h"
#include <cstdlib>
int wmain(int argc, wchar_t* argv[])
{
std::vector<std::string> args;
for (int i = 0; i < argc; ++i)
{
char buffer[1024];
std::wcstombs(buffer, argv[i], sizeof(buffer));
args.push_back(std::string(buffer));
}
CppUnit::TestRunner runner;
runner.addTest("JSONTestSuite", JSONTestSuite::suite());
return runner.run(args) ? 0 : 1;
}

View File

@@ -0,0 +1,28 @@
//
// WinDriver.cpp
//
// Windows test driver for Poco JSON.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "WinTestRunner/WinTestRunner.h"
#include "JSONTestSuite.h"
class TestDriver: public CppUnit::WinTestRunnerApp
{
void TestMain()
{
CppUnit::WinTestRunner runner;
runner.addTest(JSONTestSuite::suite());
runner.run();
}
};
TestDriver theDriver;