Commit 7e6fe1ab authored by Yann Boucher's avatar Yann Boucher
Browse files

added Eugène's files to the .pro; fixed #10 by implementing tests for Structure

parent 4b8a0359
Pipeline #76529 passed with stages
in 17 seconds
......@@ -15,9 +15,10 @@ Cette classe repr
#include <vector>
#include <utility>
#include "coord.hpp"
using namespace std;
class Coord;
class State;
/**
......@@ -51,4 +52,4 @@ public:
}
};
#endif // NEIGHBOURHOOD_HPP
\ No newline at end of file
#endif // NEIGHBOURHOOD_HPP
......@@ -47,6 +47,7 @@ class PropertyVisitor
public:
virtual ~PropertyVisitor() = default;
public:
virtual void visit(StringProperty& str) = 0;
virtual void visit(IntegerProperty& str) = 0;
virtual void visit(CoordinateProperty& coord) = 0;
......
#include "neighbourhood.hpp"
#include "neighborhood.hpp"
unsigned int Neighborhood::getNb(State state)
{
......
......@@ -13,14 +13,16 @@ INCLUDEPATH += ../include
SOURCES += \
main.cpp \
propertyvisitors.cpp
propertyvisitors.cpp \
neighborhood.cpp
HEADERS += \
../include/coord.hpp \
../include/neighborhoodrule.hpp \
../include/property.hpp \
../include/propertyvisitors.hpp \
../include/structure.hpp
../include/structure.hpp \
../include/neighborhood.hpp
# Default rules for deployment.
......
......@@ -9,6 +9,7 @@ class CellulutTests: public QObject
private slots:
void test_property();
void test_loader_saver_visitor();
void test_structure();
};
#endif // CELLULUT_TESTS_HPP
#include <QtTest/QtTest>
#include <algorithm>
#include "cellulut_tests.hpp"
#include "structure.hpp"
void CellulutTests::test_structure()
{
std::vector<std::pair<Coord, int>> coords;
std::vector<std::pair<Coord, int>> empty;
coords.push_back({{1, 2}, 0});
coords.push_back({{-1, 2}, 1});
{
Structure s1(coords.begin(), coords.end());
Structure s2;
s2.load(coords.begin(), coords.end());
QCOMPARE(s1.size(), coords.size());
QCOMPARE(s2.size(), coords.size());
QVERIFY(std::equal(coords.begin(), coords.end(), s1.begin()));
QVERIFY(std::equal(coords.begin(), coords.end(), s2.begin()));
s1.load(empty.begin(), empty.end());
QVERIFY(s1.size() == 0);
int cnt = 0;
for (auto val : s2)
{
QVERIFY(val == coords[cnt]);
++cnt;
}
}
}
......@@ -17,7 +17,8 @@ SOURCES += \
../src/propertyvisitors.cpp \
property_test.cpp \
propertyvisitors_test.cpp \
cellulut_tests.cpp
cellulut_tests.cpp \
structure_test.cpp
HEADERS += \
cellulut_tests.hpp
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment