mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-10-09 12:37: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:
127
vendor/POCO/Encodings/testsuite/src/DoubleByteEncodingTest.cpp
vendored
Normal file
127
vendor/POCO/Encodings/testsuite/src/DoubleByteEncodingTest.cpp
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// DoubleByteEncodingTest.cpp
|
||||
//
|
||||
// Copyright (c) 2018, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#include "DoubleByteEncodingTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/ISO8859_4Encoding.h"
|
||||
#include "Poco/Windows950Encoding.h"
|
||||
|
||||
|
||||
DoubleByteEncodingTest::DoubleByteEncodingTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DoubleByteEncodingTest::~DoubleByteEncodingTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DoubleByteEncodingTest::testSingleByte()
|
||||
{
|
||||
Poco::ISO8859_4Encoding enc;
|
||||
|
||||
assertTrue (std::string(enc.canonicalName()) == "ISO-8859-4");
|
||||
assertTrue (enc.isA("Latin4"));
|
||||
|
||||
unsigned char seq1[] = { 0xF8 }; // 0x00F8 LATIN SMALL LETTER O WITH STROKE
|
||||
assertTrue (enc.convert(seq1) == 0x00F8);
|
||||
assertTrue (enc.queryConvert(seq1, 1) == 0x00F8);
|
||||
assertTrue (enc.sequenceLength(seq1, 1) == 1);
|
||||
|
||||
unsigned char seq2[] = { 0xF9 }; // 0x0173 LATIN SMALL LETTER U WITH OGONEK
|
||||
assertTrue (enc.convert(seq2) == 0x0173);
|
||||
assertTrue (enc.queryConvert(seq2, 1) == 0x0173);
|
||||
assertTrue (enc.sequenceLength(seq2, 1) == 1);
|
||||
}
|
||||
|
||||
|
||||
void DoubleByteEncodingTest::testSingleByteReverse()
|
||||
{
|
||||
Poco::ISO8859_4Encoding enc;
|
||||
|
||||
unsigned char seq[2];
|
||||
|
||||
assertTrue (enc.convert(0x00F8, seq, 2) == 1);
|
||||
assertTrue (seq[0] == 0xF8);
|
||||
|
||||
assertTrue (enc.convert(0x0173, seq, 2) == 1);
|
||||
assertTrue (seq[0] == 0xF9);
|
||||
|
||||
assertTrue (enc.convert(0x3000, seq, 2) == 0);
|
||||
}
|
||||
|
||||
|
||||
void DoubleByteEncodingTest::testDoubleByte()
|
||||
{
|
||||
Poco::Windows950Encoding enc;
|
||||
|
||||
assertTrue (std::string(enc.canonicalName()) == "windows-950");
|
||||
assertTrue (enc.isA("Windows-950"));
|
||||
assertTrue (enc.isA("cp950"));
|
||||
|
||||
unsigned char seq1[] = { 0x41 }; // 0x0041 LATIN CAPITAL LETTER A
|
||||
assertTrue (enc.convert(seq1) == 0x0041);
|
||||
assertTrue (enc.queryConvert(seq1, 1) == 0x0041);
|
||||
assertTrue (enc.sequenceLength(seq1, 1) == 1);
|
||||
|
||||
unsigned char seq2[] = { 0xA1, 0x40 }; // 0x3000 IDEOGRAPHIC SPACE
|
||||
assertTrue (enc.convert(seq2) == 0x3000);
|
||||
assertTrue (enc.queryConvert(seq2, 1) == -2);
|
||||
assertTrue (enc.queryConvert(seq2, 2) == 0x3000);
|
||||
assertTrue (enc.sequenceLength(seq2, 1) == 2);
|
||||
assertTrue (enc.sequenceLength(seq2, 2) == 2);
|
||||
|
||||
unsigned char seq3[] = { 0x92 }; // invalid
|
||||
assertTrue (enc.convert(seq3) == -1);
|
||||
assertTrue (enc.queryConvert(seq3, 1) == -1);
|
||||
assertTrue (enc.sequenceLength(seq3, 1) == -1);
|
||||
}
|
||||
|
||||
|
||||
void DoubleByteEncodingTest::testDoubleByteReverse()
|
||||
{
|
||||
Poco::Windows950Encoding enc;
|
||||
|
||||
unsigned char seq[2];
|
||||
|
||||
assertTrue (enc.convert(0x0041, seq, 2) == 1);
|
||||
assertTrue (seq[0] == 0x41);
|
||||
|
||||
assertTrue (enc.convert(0x3000, seq, 2) == 2);
|
||||
assertTrue (seq[0] == 0xA1);
|
||||
assertTrue (seq[1] == 0x40);
|
||||
|
||||
assertTrue (enc.convert(0x3004, seq, 2) == 0);
|
||||
}
|
||||
|
||||
|
||||
void DoubleByteEncodingTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DoubleByteEncodingTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* DoubleByteEncodingTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DoubleByteEncodingTest");
|
||||
|
||||
CppUnit_addTest(pSuite, DoubleByteEncodingTest, testSingleByte);
|
||||
CppUnit_addTest(pSuite, DoubleByteEncodingTest, testSingleByteReverse);
|
||||
CppUnit_addTest(pSuite, DoubleByteEncodingTest, testDoubleByte);
|
||||
CppUnit_addTest(pSuite, DoubleByteEncodingTest, testDoubleByteReverse);
|
||||
|
||||
return pSuite;
|
||||
}
|
40
vendor/POCO/Encodings/testsuite/src/DoubleByteEncodingTest.h
vendored
Normal file
40
vendor/POCO/Encodings/testsuite/src/DoubleByteEncodingTest.h
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// DoubleByteEncodingTest.h
|
||||
//
|
||||
// Definition of the DoubleByteEncodingTest class.
|
||||
//
|
||||
// Copyright (c) 2018, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef DoubleByteEncodingTest_INCLUDED
|
||||
#define DoubleByteEncodingTest_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class DoubleByteEncodingTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DoubleByteEncodingTest(const std::string& name);
|
||||
~DoubleByteEncodingTest();
|
||||
|
||||
void testSingleByte();
|
||||
void testSingleByteReverse();
|
||||
void testDoubleByte();
|
||||
void testDoubleByteReverse();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // DoubleByteEncodingTest_INCLUDED
|
17
vendor/POCO/Encodings/testsuite/src/Driver.cpp
vendored
Normal file
17
vendor/POCO/Encodings/testsuite/src/Driver.cpp
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Driver.cpp
|
||||
//
|
||||
// Console-based test driver for Poco Encodings.
|
||||
//
|
||||
// Copyright (c) 2018, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestRunner.h"
|
||||
#include "EncodingsTestSuite.h"
|
||||
|
||||
|
||||
CppUnitMain(EncodingsTestSuite)
|
22
vendor/POCO/Encodings/testsuite/src/EncodingsTestSuite.cpp
vendored
Normal file
22
vendor/POCO/Encodings/testsuite/src/EncodingsTestSuite.cpp
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// EncodingsTestSuite.cpp
|
||||
//
|
||||
// Copyright (c) 2018, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#include "EncodingsTestSuite.h"
|
||||
#include "DoubleByteEncodingTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* EncodingsTestSuite::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("EncodingsTestSuite");
|
||||
|
||||
pSuite->addTest(DoubleByteEncodingTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
27
vendor/POCO/Encodings/testsuite/src/EncodingsTestSuite.h
vendored
Normal file
27
vendor/POCO/Encodings/testsuite/src/EncodingsTestSuite.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// EncodingsTestSuite.h
|
||||
//
|
||||
// Definition of the EncodingsTestSuite class.
|
||||
//
|
||||
// Copyright (c) 2018, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef EncodingsTestSuite_INCLUDED
|
||||
#define EncodingsTestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
||||
|
||||
class EncodingsTestSuite
|
||||
{
|
||||
public:
|
||||
static CppUnit::Test* suite();
|
||||
};
|
||||
|
||||
|
||||
#endif // EncodingsTestSuite_INCLUDED
|
30
vendor/POCO/Encodings/testsuite/src/WinCEDriver.cpp
vendored
Normal file
30
vendor/POCO/Encodings/testsuite/src/WinCEDriver.cpp
vendored
Normal 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 "EncodingsTestSuite.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("EncodingsTestSuite", EncodingsTestSuite::suite());
|
||||
return runner.run(args) ? 0 : 1;
|
||||
}
|
28
vendor/POCO/Encodings/testsuite/src/WinDriver.cpp
vendored
Normal file
28
vendor/POCO/Encodings/testsuite/src/WinDriver.cpp
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// WinDriver.cpp
|
||||
//
|
||||
// Windows test driver for Poco Encodings.
|
||||
//
|
||||
// Copyright (c) 2018, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#include "WinTestRunner/WinTestRunner.h"
|
||||
#include "EncodingsTestSuite.h"
|
||||
|
||||
|
||||
class TestDriver: public CppUnit::WinTestRunnerApp
|
||||
{
|
||||
void TestMain()
|
||||
{
|
||||
CppUnit::WinTestRunner runner;
|
||||
runner.addTest(EncodingsTestSuite::suite());
|
||||
runner.run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TestDriver theDriver;
|
Reference in New Issue
Block a user