mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-10 02:39:03 +08:00
now the unit-tests (hence all of Eigen) don't depend on Qt at all
anymore.
This commit is contained in:
parent
486fdb26a1
commit
b501e08d81
@ -364,8 +364,8 @@ template<typename Derived> class MatrixBase
|
|||||||
DiagonalCoeffs<Derived> diagonal();
|
DiagonalCoeffs<Derived> diagonal();
|
||||||
const DiagonalCoeffs<Derived> diagonal() const;
|
const DiagonalCoeffs<Derived> diagonal() const;
|
||||||
|
|
||||||
template<unsigned int PartType> Part<Derived, PartType> part();
|
template<unsigned int Mode> Part<Derived, Mode> part();
|
||||||
template<unsigned int ExtractType> const Extract<Derived, ExtractType> extract() const;
|
template<unsigned int Mode> const Extract<Derived, Mode> extract() const;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// \name Generating special matrices
|
/// \name Generating special matrices
|
||||||
|
@ -59,16 +59,11 @@ MACRO(EI_ADD_TEST testname)
|
|||||||
ADD_TEST(${testname} "${CMAKE_CURRENT_SOURCE_DIR}/runtest.sh" "${testname}")
|
ADD_TEST(${testname} "${CMAKE_CURRENT_SOURCE_DIR}/runtest.sh" "${testname}")
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(${targetname} ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} )
|
|
||||||
|
|
||||||
ENDMACRO(EI_ADD_TEST)
|
ENDMACRO(EI_ADD_TEST)
|
||||||
|
|
||||||
|
|
||||||
ENABLE_TESTING()
|
ENABLE_TESTING()
|
||||||
|
|
||||||
FIND_PACKAGE(Qt4 REQUIRED)
|
|
||||||
INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} )
|
|
||||||
|
|
||||||
EI_ADD_TEST(basicstuff)
|
EI_ADD_TEST(basicstuff)
|
||||||
EI_ADD_TEST(linearstructure)
|
EI_ADD_TEST(linearstructure)
|
||||||
EI_ADD_TEST(cwiseop)
|
EI_ADD_TEST(cwiseop)
|
||||||
|
36
test/main.h
36
test/main.h
@ -28,7 +28,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <Qt/QtCore>
|
|
||||||
|
|
||||||
#ifndef EIGEN_TEST_FUNC
|
#ifndef EIGEN_TEST_FUNC
|
||||||
#error EIGEN_TEST_FUNC must be defined
|
#error EIGEN_TEST_FUNC must be defined
|
||||||
@ -225,49 +224,46 @@ inline bool test_ei_isMuchSmallerThan(const MatrixBase<Derived>& m,
|
|||||||
void EI_PP_CAT(test_,EIGEN_TEST_FUNC)();
|
void EI_PP_CAT(test_,EIGEN_TEST_FUNC)();
|
||||||
|
|
||||||
using namespace Eigen;
|
using namespace Eigen;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
|
||||||
|
|
||||||
bool has_set_repeat = false;
|
bool has_set_repeat = false;
|
||||||
bool has_set_seed = false;
|
bool has_set_seed = false;
|
||||||
bool need_help = false;
|
bool need_help = false;
|
||||||
unsigned int seed = 0;
|
unsigned int seed = 0;
|
||||||
int repeat = DEFAULT_REPEAT;
|
int repeat = DEFAULT_REPEAT;
|
||||||
|
|
||||||
QStringList args = QCoreApplication::instance()->arguments();
|
for(int i = 1; i < argc; i++)
|
||||||
args.takeFirst(); // throw away the first argument (path to executable)
|
|
||||||
foreach(QString arg, args)
|
|
||||||
{
|
{
|
||||||
if(arg.startsWith("r"))
|
if(argv[i][0] == 'r')
|
||||||
{
|
{
|
||||||
if(has_set_repeat)
|
if(has_set_repeat)
|
||||||
{
|
{
|
||||||
qDebug() << "Argument" << arg << "conflicting with a former argument";
|
cout << "Argument " << argv[i] << " conflicting with a former argument" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
repeat = arg.remove(0, 1).toInt();
|
repeat = atoi(argv[i]+1);
|
||||||
has_set_repeat = true;
|
has_set_repeat = true;
|
||||||
if(repeat <= 0)
|
if(repeat <= 0)
|
||||||
{
|
{
|
||||||
qDebug() << "Invalid \'repeat\' value" << arg;
|
cout << "Invalid \'repeat\' value " << argv[i]+1 << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(arg.startsWith("s"))
|
else if(argv[i][0] == 's')
|
||||||
{
|
{
|
||||||
if(has_set_seed)
|
if(has_set_seed)
|
||||||
{
|
{
|
||||||
qDebug() << "Argument" << arg << "conflicting with a former argument";
|
cout << "Argument " << argv[i] << " conflicting with a former argument" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
bool ok;
|
seed = strtoul(argv[i]+1, 0, 10);
|
||||||
seed = arg.remove(0, 1).toUInt(&ok);
|
|
||||||
has_set_seed = true;
|
has_set_seed = true;
|
||||||
|
bool ok = seed!=0;
|
||||||
if(!ok)
|
if(!ok)
|
||||||
{
|
{
|
||||||
qDebug() << "Invalid \'seed\' value" << arg;
|
cout << "Invalid \'seed\' value " << argv[i]+1 << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,18 +275,18 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if(need_help)
|
if(need_help)
|
||||||
{
|
{
|
||||||
qDebug() << "This test application takes the following optional arguments:";
|
cout << "This test application takes the following optional arguments:" << endl;
|
||||||
qDebug() << " rN Repeat each test N times (default:" << DEFAULT_REPEAT << ")";
|
cout << " rN Repeat each test N times (default: " << DEFAULT_REPEAT << ")" << endl;
|
||||||
qDebug() << " sN Use N as seed for random numbers (default: based on current time)";
|
cout << " sN Use N as seed for random numbers (default: based on current time)" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!has_set_seed) seed = (unsigned int) time(NULL);
|
if(!has_set_seed) seed = (unsigned int) time(NULL);
|
||||||
if(!has_set_repeat) repeat = DEFAULT_REPEAT;
|
if(!has_set_repeat) repeat = DEFAULT_REPEAT;
|
||||||
|
|
||||||
qDebug() << "Initializing random number generator with seed" << seed;
|
cout << "Initializing random number generator with seed " << seed << endl;
|
||||||
srand(seed);
|
srand(seed);
|
||||||
qDebug() << "Repeating each test" << repeat << "times";
|
cout << "Repeating each test " << repeat << " times" << endl;
|
||||||
|
|
||||||
Eigen::g_repeat = repeat;
|
Eigen::g_repeat = repeat;
|
||||||
Eigen::g_test_stack.push_back(EI_PP_MAKE_STRING(EIGEN_TEST_FUNC));
|
Eigen::g_test_stack.push_back(EI_PP_MAKE_STRING(EIGEN_TEST_FUNC));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user