##// END OF EJS Templates
push method of worker return the id of the nextRange which is canceled
push method of worker return the id of the nextRange which is canceled

File last commit:

r578:2266e13252d4
r584:d6648352006d
Show More
TestDataSeries.cpp
522 lines | 19.8 KiB | text/x-c | CppLexer
/ core / tests / Data / TestDataSeries.cpp
Alexandre Leroux
Units tests on sorting data series
r421 #include "Data/DataSeries.h"
#include "Data/ScalarSeries.h"
Alexandre Leroux
Makes unit test templated to use it for vectors too
r572 #include "Data/VectorSeries.h"
Alexandre Leroux
Units tests on sorting data series
r421
Alexandre Leroux
Fixes compilation on linux
r577 #include <cmath>
Alexandre Leroux
Units tests on sorting data series
r421 #include <QObject>
#include <QtTest>
Q_DECLARE_METATYPE(std::shared_ptr<ScalarSeries>)
Alexandre Leroux
Makes unit test templated to use it for vectors too
r572 Q_DECLARE_METATYPE(std::shared_ptr<VectorSeries>)
Alexandre Leroux
Units tests on sorting data series
r421
class TestDataSeries : public QObject {
Q_OBJECT
Alexandre Leroux
Makes unit test templated to use it for vectors too
r572 private:
template <typename T>
void testValuesBoundsStructure()
{
// ////////////// //
// Test structure //
// ////////////// //
// Data series to get values bounds
QTest::addColumn<std::shared_ptr<T> >("dataSeries");
// x-axis range
QTest::addColumn<double>("minXAxis");
QTest::addColumn<double>("maxXAxis");
// Expected results
QTest::addColumn<bool>(
"expectedOK"); // Test is expected to be ok (i.e. method doesn't return end iterators)
QTest::addColumn<double>("expectedMinValue");
QTest::addColumn<double>("expectedMaxValue");
}
template <typename T>
void testValuesBounds()
{
QFETCH(std::shared_ptr<T>, dataSeries);
QFETCH(double, minXAxis);
QFETCH(double, maxXAxis);
QFETCH(bool, expectedOK);
QFETCH(double, expectedMinValue);
QFETCH(double, expectedMaxValue);
auto minMaxIts = dataSeries->valuesBounds(minXAxis, maxXAxis);
auto end = dataSeries->cend();
// Checks iterators with expected result
QCOMPARE(expectedOK, minMaxIts.first != end && minMaxIts.second != end);
if (expectedOK) {
auto compare = [](const auto &v1, const auto &v2) {
return (std::isnan(v1) && std::isnan(v2)) || v1 == v2;
};
QVERIFY(compare(expectedMinValue, minMaxIts.first->minValue()));
QVERIFY(compare(expectedMaxValue, minMaxIts.second->maxValue()));
}
}
Alexandre Leroux
Units tests on sorting data series
r421 private slots:
/// Input test data
/// @sa testCtor()
void testCtor_data();
/// Tests construction of a data series
void testCtor();
/// Input test data
/// @sa testMerge()
void testMerge_data();
/// Tests merge of two data series
void testMerge();
Alexandre Leroux
Fixes subData() method and adds unit tests
r550
/// Input test data
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r565 /// @sa testMinXAxisData()
void testMinXAxisData_data();
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r565 /// Tests get min x-axis data of a data series
void testMinXAxisData();
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562 /// Input test data
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r565 /// @sa testMaxXAxisData()
void testMaxXAxisData_data();
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r565 /// Tests get max x-axis data of a data series
void testMaxXAxisData();
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562
/// Input test data
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 /// @sa testXAxisRange()
void testXAxisRange_data();
Alexandre Leroux
Fixes subData() method and adds unit tests
r550
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 /// Tests get x-axis range of a data series
void testXAxisRange();
Alexandre Leroux
Makes unit tests
r571
/// Input test data
Alexandre Leroux
Makes unit test templated to use it for vectors too
r572 /// @sa testValuesBoundsScalar()
void testValuesBoundsScalar_data();
Alexandre Leroux
Makes unit tests
r571
Alexandre Leroux
Makes unit test templated to use it for vectors too
r572 /// Tests get values bounds of a scalar series
void testValuesBoundsScalar();
Alexandre Leroux
Implements unit tests for vectors
r573
/// Input test data
/// @sa testValuesBoundsVector()
void testValuesBoundsVector_data();
/// Tests get values bounds of a vector series
void testValuesBoundsVector();
Alexandre Leroux
Units tests on sorting data series
r421 };
void TestDataSeries::testCtor_data()
{
// ////////////// //
// Test structure //
// ////////////// //
// x-axis data
QTest::addColumn<QVector<double> >("xAxisData");
// values data
QTest::addColumn<QVector<double> >("valuesData");
// expected x-axis data
QTest::addColumn<QVector<double> >("expectedXAxisData");
// expected values data
QTest::addColumn<QVector<double> >("expectedValuesData");
// ////////// //
// Test cases //
// ////////// //
QTest::newRow("invalidData (different sizes of vectors)")
<< QVector<double>{1., 2., 3., 4., 5.} << QVector<double>{100., 200., 300.}
<< QVector<double>{} << QVector<double>{};
QTest::newRow("sortedData") << QVector<double>{1., 2., 3., 4., 5.}
<< QVector<double>{100., 200., 300., 400., 500.}
<< QVector<double>{1., 2., 3., 4., 5.}
<< QVector<double>{100., 200., 300., 400., 500.};
QTest::newRow("unsortedData") << QVector<double>{5., 4., 3., 2., 1.}
<< QVector<double>{100., 200., 300., 400., 500.}
<< QVector<double>{1., 2., 3., 4., 5.}
<< QVector<double>{500., 400., 300., 200., 100.};
QTest::newRow("unsortedData2")
<< QVector<double>{1., 4., 3., 5., 2.} << QVector<double>{100., 200., 300., 400., 500.}
<< QVector<double>{1., 2., 3., 4., 5.} << QVector<double>{100., 500., 300., 200., 400.};
}
void TestDataSeries::testCtor()
{
// Creates series
QFETCH(QVector<double>, xAxisData);
QFETCH(QVector<double>, valuesData);
auto series = std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData),
Unit{}, Unit{});
// Validates results : we check that the data series is sorted on its x-axis data
QFETCH(QVector<double>, expectedXAxisData);
QFETCH(QVector<double>, expectedValuesData);
auto seriesXAxisData = series->xAxisData()->data();
auto seriesValuesData = series->valuesData()->data();
QVERIFY(
std::equal(expectedXAxisData.cbegin(), expectedXAxisData.cend(), seriesXAxisData.cbegin()));
QVERIFY(std::equal(expectedValuesData.cbegin(), expectedValuesData.cend(),
seriesValuesData.cbegin()));
}
namespace {
Alexandre Leroux
Minor refactoring
r574 std::shared_ptr<ScalarSeries> createScalarSeries(QVector<double> xAxisData,
QVector<double> valuesData)
Alexandre Leroux
Units tests on sorting data series
r421 {
return std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData), Unit{},
Unit{});
}
Alexandre Leroux
Implements unit tests for vectors
r573 std::shared_ptr<VectorSeries> createVectorSeries(QVector<double> xAxisData,
QVector<double> xValuesData,
QVector<double> yValuesData,
QVector<double> zValuesData)
{
return std::make_shared<VectorSeries>(std::move(xAxisData), std::move(xValuesData),
std::move(yValuesData), std::move(zValuesData), Unit{},
Unit{});
}
Alexandre Leroux
Units tests on sorting data series
r421 } // namespace
void TestDataSeries::testMerge_data()
{
// ////////////// //
// Test structure //
// ////////////// //
// Data series to merge
QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries");
QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries2");
// Expected values in the first data series after merge
QTest::addColumn<QVector<double> >("expectedXAxisData");
QTest::addColumn<QVector<double> >("expectedValuesData");
// ////////// //
// Test cases //
// ////////// //
QTest::newRow("sortedMerge")
Alexandre Leroux
Minor refactoring
r574 << createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
<< createScalarSeries({6., 7., 8., 9., 10.}, {600., 700., 800., 900., 1000.})
Alexandre Leroux
Units tests on sorting data series
r421 << QVector<double>{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.}
<< QVector<double>{100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.};
QTest::newRow("unsortedMerge")
Alexandre Leroux
Minor refactoring
r574 << createScalarSeries({6., 7., 8., 9., 10.}, {600., 700., 800., 900., 1000.})
<< createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.})
Alexandre Leroux
Units tests on sorting data series
r421 << QVector<double>{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.}
<< QVector<double>{100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.};
QTest::newRow("unsortedMerge2")
Alexandre Leroux
Minor refactoring
r574 << createScalarSeries({1., 2., 8., 9., 10}, {100., 200., 300., 400., 500.})
<< createScalarSeries({3., 4., 5., 6., 7.}, {600., 700., 800., 900., 1000.})
Alexandre Leroux
Units tests on sorting data series
r421 << QVector<double>{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.}
<< QVector<double>{100., 200., 600., 700., 800., 900., 1000., 300., 400., 500.};
QTest::newRow("unsortedMerge3")
Alexandre Leroux
Minor refactoring
r574 << createScalarSeries({3., 5., 8., 7., 2}, {100., 200., 300., 400., 500.})
<< createScalarSeries({6., 4., 9., 10., 1.}, {600., 700., 800., 900., 1000.})
Alexandre Leroux
Units tests on sorting data series
r421 << QVector<double>{1., 2., 3., 4., 5., 6., 7., 8., 9., 10.}
<< QVector<double>{1000., 500., 100., 700., 200., 600., 400., 300., 800., 900.};
}
void TestDataSeries::testMerge()
{
// Merges series
QFETCH(std::shared_ptr<ScalarSeries>, dataSeries);
QFETCH(std::shared_ptr<ScalarSeries>, dataSeries2);
dataSeries->merge(dataSeries2.get());
// Validates results : we check that the merge is valid and the data series is sorted on its
// x-axis data
QFETCH(QVector<double>, expectedXAxisData);
QFETCH(QVector<double>, expectedValuesData);
auto seriesXAxisData = dataSeries->xAxisData()->data();
auto seriesValuesData = dataSeries->valuesData()->data();
QVERIFY(
std::equal(expectedXAxisData.cbegin(), expectedXAxisData.cend(), seriesXAxisData.cbegin()));
QVERIFY(std::equal(expectedValuesData.cbegin(), expectedValuesData.cend(),
seriesValuesData.cbegin()));
}
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r565 void TestDataSeries::testMinXAxisData_data()
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561 {
// ////////////// //
// Test structure //
// ////////////// //
// Data series to get min data
QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries");
// Min data
QTest::addColumn<double>("min");
// Expected results
QTest::addColumn<bool>(
"expectedOK"); // if true, expects to have a result (i.e. the iterator != end iterator)
QTest::addColumn<double>(
"expectedMin"); // Expected value when method doesn't return end iterator
// ////////// //
// Test cases //
// ////////// //
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("minData1") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561 << 0. << true << 1.;
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("minData2") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561 << 1. << true << 1.;
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("minData3") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561 << 1.1 << true << 2.;
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("minData4") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561 << 5. << true << 5.;
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("minData5") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561 << 5.1 << false << std::numeric_limits<double>::quiet_NaN();
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("minData6") << createScalarSeries({}, {}) << 1.1 << false
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561 << std::numeric_limits<double>::quiet_NaN();
}
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r565 void TestDataSeries::testMinXAxisData()
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561 {
QFETCH(std::shared_ptr<ScalarSeries>, dataSeries);
QFETCH(double, min);
QFETCH(bool, expectedOK);
QFETCH(double, expectedMin);
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r565 auto it = dataSeries->minXAxisData(min);
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r561
QCOMPARE(expectedOK, it != dataSeries->cend());
// If the method doesn't return a end iterator, checks with expected value
if (expectedOK) {
QCOMPARE(expectedMin, it->x());
}
}
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r565 void TestDataSeries::testMaxXAxisData_data()
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562 {
// ////////////// //
// Test structure //
// ////////////// //
// Data series to get max data
QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries");
// Max data
QTest::addColumn<double>("max");
// Expected results
QTest::addColumn<bool>(
"expectedOK"); // if true, expects to have a result (i.e. the iterator != end iterator)
QTest::addColumn<double>(
"expectedMax"); // Expected value when method doesn't return end iterator
// ////////// //
// Test cases //
// ////////// //
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("maxData1") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562 << 6. << true << 5.;
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("maxData2") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562 << 5. << true << 5.;
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("maxData3") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562 << 4.9 << true << 4.;
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("maxData4") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562 << 1.1 << true << 1.;
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("maxData5") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562 << 1. << true << 1.;
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("maxData6") << createScalarSeries({}, {}) << 1.1 << false
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562 << std::numeric_limits<double>::quiet_NaN();
}
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r565 void TestDataSeries::testMaxXAxisData()
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562 {
QFETCH(std::shared_ptr<ScalarSeries>, dataSeries);
QFETCH(double, max);
QFETCH(bool, expectedOK);
QFETCH(double, expectedMax);
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r565 auto it = dataSeries->maxXAxisData(max);
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r562
QCOMPARE(expectedOK, it != dataSeries->cend());
// If the method doesn't return a end iterator, checks with expected value
if (expectedOK) {
QCOMPARE(expectedMax, it->x());
}
}
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 void TestDataSeries::testXAxisRange_data()
Alexandre Leroux
Fixes subData() method and adds unit tests
r550 {
// ////////////// //
// Test structure //
// ////////////// //
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 // Data series to get x-axis range
Alexandre Leroux
Fixes subData() method and adds unit tests
r550 QTest::addColumn<std::shared_ptr<ScalarSeries> >("dataSeries");
// Min/max values
QTest::addColumn<double>("min");
QTest::addColumn<double>("max");
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 // Expected values
Alexandre Leroux
Fixes subData() method and adds unit tests
r550 QTest::addColumn<QVector<double> >("expectedXAxisData");
QTest::addColumn<QVector<double> >("expectedValuesData");
// ////////// //
// Test cases //
// ////////// //
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("xAxisRange1") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 << -1. << 3.2 << QVector<double>{1., 2., 3.}
<< QVector<double>{100., 200., 300.};
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("xAxisRange2") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 << 1. << 4. << QVector<double>{1., 2., 3., 4.}
<< QVector<double>{100., 200., 300., 400.};
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("xAxisRange3") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 << 1. << 3.9 << QVector<double>{1., 2., 3.}
<< QVector<double>{100., 200., 300.};
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("xAxisRange4") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 << 0. << 0.9 << QVector<double>{} << QVector<double>{};
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("xAxisRange5") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 << 0. << 1. << QVector<double>{1.} << QVector<double>{100.};
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("xAxisRange6") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 << 2.1 << 6. << QVector<double>{3., 4., 5.}
<< QVector<double>{300., 400., 500.};
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("xAxisRange7") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 << 6. << 9. << QVector<double>{} << QVector<double>{};
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("xAxisRange8") << createScalarSeries({1., 2., 3., 4., 5.},
{100., 200., 300., 400., 500.})
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 << 5. << 9. << QVector<double>{5.} << QVector<double>{500.};
Alexandre Leroux
Fixes subData() method and adds unit tests
r550 }
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 void TestDataSeries::testXAxisRange()
Alexandre Leroux
Fixes subData() method and adds unit tests
r550 {
QFETCH(std::shared_ptr<ScalarSeries>, dataSeries);
QFETCH(double, min);
QFETCH(double, max);
QFETCH(QVector<double>, expectedXAxisData);
QFETCH(QVector<double>, expectedValuesData);
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r566 auto bounds = dataSeries->xAxisRange(min, max);
Alexandre Leroux
Fixes subData() method and adds unit tests
r550 QVERIFY(std::equal(bounds.first, bounds.second, expectedXAxisData.cbegin(),
expectedXAxisData.cend(),
[](const auto &it, const auto &expectedX) { return it.x() == expectedX; }));
QVERIFY(std::equal(
bounds.first, bounds.second, expectedValuesData.cbegin(), expectedValuesData.cend(),
[](const auto &it, const auto &expectedVal) { return it.value() == expectedVal; }));
}
Alexandre Leroux
Makes unit test templated to use it for vectors too
r572 void TestDataSeries::testValuesBoundsScalar_data()
Alexandre Leroux
Makes unit tests
r571 {
Alexandre Leroux
Makes unit test templated to use it for vectors too
r572 testValuesBoundsStructure<ScalarSeries>();
Alexandre Leroux
Makes unit tests
r571
// ////////// //
// Test cases //
// ////////// //
Alexandre Leroux
Minor refactoring
r574 auto nan = std::numeric_limits<double>::quiet_NaN();
QTest::newRow("scalarBounds1")
<< createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) << 0. << 6.
<< true << 100. << 500.;
QTest::newRow("scalarBounds2")
<< createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) << 2. << 4.
<< true << 200. << 400.;
QTest::newRow("scalarBounds3")
<< createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) << 0. << 0.5
<< false << nan << nan;
QTest::newRow("scalarBounds4")
<< createScalarSeries({1., 2., 3., 4., 5.}, {100., 200., 300., 400., 500.}) << 5.1 << 6.
<< false << nan << nan;
Correction clang format for Linux
r578 QTest::newRow("scalarBounds5") << createScalarSeries({1.}, {100.}) << 0. << 2. << true << 100.
<< 100.;
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("scalarBounds6") << createScalarSeries({}, {}) << 0. << 2. << false << nan << nan;
Alexandre Leroux
Makes unit tests
r571
// Tests with NaN values: NaN values are not included in min/max search
Alexandre Leroux
Minor refactoring
r574 QTest::newRow("scalarBounds7")
<< createScalarSeries({1., 2., 3., 4., 5.}, {nan, 200., 300., 400., nan}) << 0. << 6.
<< true << 200. << 400.;
QTest::newRow("scalarBounds8")
<< createScalarSeries({1., 2., 3., 4., 5.}, {nan, nan, nan, nan, nan}) << 0. << 6. << true
<< std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN();
Alexandre Leroux
Makes unit tests
r571 }
Alexandre Leroux
Makes unit test templated to use it for vectors too
r572 void TestDataSeries::testValuesBoundsScalar()
Alexandre Leroux
Makes unit tests
r571 {
Alexandre Leroux
Makes unit test templated to use it for vectors too
r572 testValuesBounds<ScalarSeries>();
Alexandre Leroux
Makes unit tests
r571 }
Alexandre Leroux
Implements unit tests for vectors
r573 void TestDataSeries::testValuesBoundsVector_data()
{
testValuesBoundsStructure<VectorSeries>();
// ////////// //
// Test cases //
// ////////// //
Alexandre Leroux
Minor refactoring
r574 auto nan = std::numeric_limits<double>::quiet_NaN();
Alexandre Leroux
Implements unit tests for vectors
r573
QTest::newRow("vectorBounds1")
<< createVectorSeries({1., 2., 3., 4., 5.}, {10., 15., 20., 13., 12.},
{35., 24., 10., 9., 0.3}, {13., 14., 12., 9., 24.})
<< 0. << 6. << true << 0.3 << 35.; // min/max in same component
QTest::newRow("vectorBounds2")
<< createVectorSeries({1., 2., 3., 4., 5.}, {2.3, 15., 20., 13., 12.},
{35., 24., 10., 9., 4.}, {13., 14., 12., 9., 24.})
<< 0. << 6. << true << 2.3 << 35.; // min/max in same entry
QTest::newRow("vectorBounds3")
<< createVectorSeries({1., 2., 3., 4., 5.}, {2.3, 15., 20., 13., 12.},
{35., 24., 10., 9., 4.}, {13., 14., 12., 9., 24.})
<< 2. << 3. << true << 10. << 24.;
// Tests with NaN values: NaN values are not included in min/max search
QTest::newRow("vectorBounds4")
Alexandre Leroux
Minor refactoring
r574 << createVectorSeries({1., 2.}, {nan, nan}, {nan, nan}, {nan, nan}) << 0. << 6. << true
<< nan << nan;
Alexandre Leroux
Implements unit tests for vectors
r573 }
void TestDataSeries::testValuesBoundsVector()
{
testValuesBounds<VectorSeries>();
}
Alexandre Leroux
Units tests on sorting data series
r421 QTEST_MAIN(TestDataSeries)
#include "TestDataSeries.moc"