Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,28 @@
#
# @RDE_HEADER@
# $Id$
# $HeadURL$
# $Author$
#
SET(UnitTestSources
tne_algo_unit_test.cpp
tne_algo_unit_test.h
)
SOURCE_GROUP( UnitTestSources FILES ${UnitTestSources} )
IF(BUILD_TESTING)
ADD_EXECUTABLE(aesUnitTestTneAlgorithmen ${LinkedSources} ${UnitTestSources} )
TARGET_LINK_LIBRARIES(aesUnitTestTneAlgorithmen
NGLLogger
nglcoreapplication
Qt5::Core
Qt5::Test
svcAesCommon
)
ADD_TEST(NAME aesUnitTestTneAlgorithmen COMMAND $<TARGET_FILE:aesUnitTestTneAlgorithmen>)
ENDIF()
@@ -0,0 +1,142 @@
/**
* @RDE_HEADER@
* Unittest
* $Id$
* $HeadURL$
* $Author$
*/
#include "tne_algo_unit_test.h"
#include <Services/AreaEffectSimulation/Utils/tne_algorithmen.h>
#include <nglapplication/nglcoreapplication.h>
#include <QtTest/QTest>
#include <QFile>
#include <QDir>
#include <iostream>
using namespace AreaEffectSimulation;
//
//
// This class is an UnitTest with values taken from the TNE.
// That was created while Michael Moetje was implementing that code at the TNE (PlayerUnit)
//
//
void UnitTestVerteilung::test_long()
{
int size = sizeof(int);
std::cout << " sizeof 'int' " << size << std::endl;
size = sizeof(long);
std::cout << " sizeof 'long' " << size << std::endl;
size = sizeof(long long);
std::cout << " sizeof 'long long' " << size << std::endl;
size = sizeof(qint32);
std::cout << " sizeof 'qint32g' " << size << std::endl;
}
void UnitTestVerteilung::test_xorshift32()
{
// 1
ULONG pxInOut = 123;
ushort ret = TNE_ALGORITHMEN::xorshift32(&pxInOut);
std::cout << " test_xorshift32 ret: " << ret << std::endl;
QVERIFY2(ret == 28668, "xorshift32 failed");
}
void UnitTestVerteilung::test_xorshift32_nv()
{
ULONG _generator = 123;
short _bereich = 500;
// _generator = 123, _bereich = 500 => laut Moetje: -73, 93, -79, -321, -25
int ret = TNE_ALGORITHMEN::xorshift32_nv(&_generator, _bereich, 3);
std::cout << " xorshift32_nv ret: " << ret << std::endl;
QVERIFY2(ret == -73, "xorshift32_nv failed");
ret = TNE_ALGORITHMEN::xorshift32_nv(&_generator, _bereich, 3);
std::cout << " xorshift32_nv ret: " << ret << std::endl;
QVERIFY2(ret == 93, "xorshift32_nv failed");
ret = TNE_ALGORITHMEN::xorshift32_nv(&_generator, _bereich, 3);
std::cout << " xorshift32_nv ret: " << ret << std::endl;
QVERIFY2(ret == -79, "xorshift32_nv failed");
ret = TNE_ALGORITHMEN::xorshift32_nv(&_generator, _bereich, 3);
std::cout << " xorshift32_nv ret: " << ret << std::endl;
QVERIFY2(ret == -321, "xorshift32_nv failed");
ret = TNE_ALGORITHMEN::xorshift32_nv(&_generator, _bereich, 3);
std::cout << " xorshift32_nv ret: " << ret << std::endl;
QVERIFY2(ret == -25, "xorshift32_nv failed");
}
void UnitTestVerteilung::test_xorshift32_nv_saveToFile()
{
ULONG _generator = 123;
SHORT _bereich = 500;
QString tempDir = QDir::tempPath();
QFile file(tempDir + QDir::separator() + QStringLiteral("tne_algorithmen_xorshift32_nv_data.txt"));
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out(&file);
out << "Test vom Algorithmus 'xorshift32_nv'" << "\n";
out << "_generator = " << _generator << "\n";
out << "_bereich = " << _bereich << "\n";
out << " Start " << "\n";
for (int i = 0; i < 1000; ++i)
{
out << "_generator = " << _generator;
int ret = TNE_ALGORITHMEN::xorshift32_nv(&_generator, _bereich, 3);
std::cout << " test_xorshift32_nv ret: " << ret << std::endl;
out << " -> erzeugter Wert = " << ret << "\n";
}
out << "Ende :-)" << "\n";
}
void UnitTestVerteilung::test_areaExlosionGAUSS()
{
const int wirkfeldKennung = 4711;
const int breite_m = 500; // Vielfaches von 5m
const int tiefe_m = 50; // Vielfaches von 5m
const int anzahl_einschlaege = 10;
QVector<QPointF> impacts = TNE_ALGORITHMEN::areaExlosionsGAUSS(wirkfeldKennung,
breite_m, tiefe_m,
anzahl_einschlaege);
QVERIFY2(impacts.size() == anzahl_einschlaege, "test_areaExlosionGAUSS failed");
QVERIFY2(impacts[0] == QPointF(206, 29), "test_areaExlosionGAUSS failed");
QVERIFY2(impacts[1] == QPointF(252, 42), "test_areaExlosionGAUSS failed");
QVERIFY2(impacts[2] == QPointF(110, 21), "test_areaExlosionGAUSS failed");
QVERIFY2(impacts[3] == QPointF(209, 32), "test_areaExlosionGAUSS failed");
}
int main(int argc, char *argv[])
{
NGLCoreApplication app(argc, argv);
app.createLogger("UnitTest_TNE-ALOG", "log4cxxUnitTest.props");
UnitTestVerteilung tc;
return QTest::qExec(&tc, argc, argv);
}
@@ -0,0 +1,45 @@
/**
* @RDE_HEADER@
* Unittest
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <QCoreApplication>
#include <QtTest/QTest>
using ULONG = quint32;
using LONG = qint32;
using SHORT = qint32;
/**
* @brief This class is an UnitTest with values taken from the TNE.
* That was created while Michael Moetje was implementing that code at the TNE (PlayerUnit)
*/
class UnitTestVerteilung : public QObject
{
Q_OBJECT
private Q_SLOTS:
// void init();
void test_long();
void test_xorshift32();
void test_xorshift32_nv();
void test_xorshift32_nv_saveToFile();
void test_areaExlosionGAUSS();
// void cleanup();
private:
};