- Created 139 test files covering all Lts/Common module components - Includes tests for CodeGen, LtsAppDescriptor, LtsAppManager, LtsCoordTrans, LtsElevation, LtsLicence, LtsLogin, LtsMultiMonitor, LtsNotification, LtsPluginManager, LtsProtocol, LtsProjection, VNC, and CustomViews - Updated tests/CMakeLists.txt with dynamic file(GLOB) for test collection - Moved coordTransTests from CommonUnitTestsPlaceholder/ to tests/ - All tests follow policy naming conventions (test_<name>.cpp) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
79 lines
2.2 KiB
C++
79 lines
2.2 KiB
C++
/**
|
|
* @file test_qt6_compatibility.cpp
|
|
* @brief Tests für Qt6-Kompatibilitätsfixes
|
|
*
|
|
* Tests verify that:
|
|
* 1. QRandomGenerator works correctly (replacing qrand())
|
|
* 2. QChar conversions work with static_cast<ushort>
|
|
* 3. Qt6 APIs function correctly
|
|
*/
|
|
|
|
#include <gtest/gtest.h>
|
|
#include <QRandomGenerator>
|
|
#include <QChar>
|
|
#include <QString>
|
|
#include <QStringView>
|
|
#include <QVector>
|
|
|
|
// Test 1: QRandomGenerator basic functionality
|
|
TEST(Qt6Compatibility, QRandomGeneratorBasic) {
|
|
// Test bounded random number generation (Qt6 replacement for qrand() % n)
|
|
auto* generator = QRandomGenerator::global();
|
|
ASSERT_NE(generator, nullptr);
|
|
|
|
int value = generator->bounded(100);
|
|
EXPECT_GE(value, 0);
|
|
EXPECT_LT(value, 100);
|
|
}
|
|
|
|
// Test 2: QRandomGenerator seeded generation
|
|
TEST(Qt6Compatibility, QRandomGeneratorSeeded) {
|
|
QRandomGenerator generator(42); // Fixed seed for reproducibility
|
|
int value1 = generator.bounded(1000);
|
|
|
|
QRandomGenerator generator2(42); // Same seed
|
|
int value2 = generator2.bounded(1000);
|
|
|
|
EXPECT_EQ(value1, value2); // Should produce same sequence
|
|
}
|
|
|
|
// Test 3: QChar construction with static_cast<ushort>
|
|
TEST(Qt6Compatibility, QCharConstruction) {
|
|
// Qt6 has stricter QChar constructors
|
|
char c = 'A';
|
|
QChar qchar = QChar(static_cast<ushort>(c));
|
|
EXPECT_EQ(qchar, QChar('A'));
|
|
}
|
|
|
|
// Test 4: QChar Unicode handling
|
|
TEST(Qt6Compatibility, QCharUnicode) {
|
|
// Test Unicode character handling in Qt6
|
|
QChar unicodeChar(0x00E9); // é
|
|
EXPECT_EQ(unicodeChar.unicode(), 0x00E9);
|
|
|
|
QString str(unicodeChar);
|
|
EXPECT_EQ(str, QString("é"));
|
|
}
|
|
|
|
// Test 5: QVector with Qt6
|
|
TEST(Qt6Compatibility, QVectorBasic) {
|
|
QVector<int> vec;
|
|
vec.append(1);
|
|
vec.append(2);
|
|
vec.append(3);
|
|
|
|
EXPECT_EQ(vec.size(), 3);
|
|
EXPECT_EQ(vec[0], 1);
|
|
EXPECT_EQ(vec.contains(2), true);
|
|
}
|
|
|
|
// Test 6: QString Qt6 compatibility
|
|
TEST(Qt6Compatibility, QStringBasic) {
|
|
QString str = "Hello Qt6";
|
|
EXPECT_EQ(str.length(), 9);
|
|
EXPECT_TRUE(str.contains("Qt6"));
|
|
|
|
// Test Qt6 string methods - use QStringView instead of toStdStringView
|
|
QStringView view = str;
|
|
EXPECT_EQ(view.size(), 9);
|
|
} |