Add tests for rule 3 and 4
parent
0120df8102
commit
646e3a352b
13
meson.build
13
meson.build
|
@ -5,9 +5,10 @@ project('sirEdit', ['cpp'],
|
|||
|
||||
cmake = import('cmake')
|
||||
cpp = meson.get_compiler('cpp')
|
||||
openmp = cpp.find_library('gomp')
|
||||
openmp = cpp.find_library('gomp', required : false)
|
||||
cppCommon = cmake.subproject('cppCommon')
|
||||
skillLib = cppCommon.dependency('skill_cpp_common')
|
||||
gtest = dependency('gtest', main : true, required : false)
|
||||
|
||||
thread_dep = dependency('threads')
|
||||
gtkmm = dependency('gtkmm-3.0', version: '>= 3.18')
|
||||
|
@ -57,6 +58,14 @@ src_siredit = [
|
|||
]
|
||||
inc_siredit = include_directories('include')
|
||||
|
||||
# SirEdit tests
|
||||
src_siredit_test = [
|
||||
'src/unittests/rules/rule1.cpp',
|
||||
'src/unittests/rules/rule2.cpp',
|
||||
'src/unittests/rules/rule3.cpp',
|
||||
'src/unittests/rules/rule4.cpp'
|
||||
]
|
||||
|
||||
# Resource encoding
|
||||
resource_encoder = executable('resource_encoder', ['resource_encoder.cpp'], native: true)
|
||||
src_resources = [
|
||||
|
@ -71,3 +80,5 @@ src_resources = [
|
|||
]
|
||||
|
||||
executable('sirEdit', src_sir + src_siredit + src_resources, cpp_args: '-std=c++17', dependencies: [gtkmm, skillLib, openmp, thread_dep], include_directories: [inc_sir, inc_siredit], install: true)
|
||||
sirEdit_test = executable('sirEdit_test', src_siredit_test, cpp_args: '-std=c++17', dependencies: [openmp, gtest], include_directories: [inc_siredit])
|
||||
test('sirEdit tests', sirEdit_test)
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
#include <sirEdit/data/types.hpp>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace {
|
||||
using namespace sirEdit::data;
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* Solves problemes for models
|
||||
*/
|
||||
class ModelHelper {
|
||||
public:
|
||||
|
||||
private:
|
||||
unordered_multimap<string, Type*> __types;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Adds a type to update
|
||||
* @param type The type to add
|
||||
* @param name The type name to set
|
||||
*/
|
||||
void _addType(Type& type) {
|
||||
this->__types.insert({type.getName(), &type});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates fields of types and fiedls
|
||||
*/
|
||||
void _update() {
|
||||
// Clear up types
|
||||
for(auto& i : this->__types)
|
||||
i.second->getSubTypes().clear();
|
||||
|
||||
// Update subtypes
|
||||
for(auto& i : this->__types) {
|
||||
// Find super
|
||||
Type* super = const_cast<Type*>(getSuper(*(i.second)));
|
||||
|
||||
// Add to subtypes list
|
||||
super->getSubTypes().push_back(i.second);
|
||||
}
|
||||
|
||||
// TODO: Type inconsistent
|
||||
// TODO: Fields
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Model to to test type rules
|
||||
*
|
||||
* g(c) <- h(e)
|
||||
* |
|
||||
* v
|
||||
* a(c) <- b(i)
|
||||
* ^ ^
|
||||
* | |
|
||||
* c(i) <- d(c) <- e(c)
|
||||
* ^
|
||||
* |
|
||||
* f(td)
|
||||
*
|
||||
* i(c)
|
||||
*/
|
||||
class TypeTestModel1 : ModelHelper {
|
||||
public:
|
||||
TypeClass a = {"a", "", {}, {}, nullptr};
|
||||
TypeInterface b = {"b", "", {}, {}, &a};
|
||||
TypeInterface c = {"c", "", {}, {}, &a};
|
||||
TypeClass d = {"d", "", {}, {&b, &c}, nullptr};
|
||||
TypeClass e = {"e", "", {}, {}, &d};
|
||||
TypeTypedef f = {"f", "", &i};
|
||||
TypeClass g = {"g", "", {}, {}, &a};
|
||||
TypeEnum h = {"h", "", {}, {}, &g};
|
||||
TypeClass i = {"i", "", {}, {}, nullptr};
|
||||
|
||||
TypeTestModel1() {
|
||||
this->_addType(this->a);
|
||||
this->_addType(this->b);
|
||||
this->_addType(this->c);
|
||||
this->_addType(this->d);
|
||||
this->_addType(this->e);
|
||||
this->_addType(this->f);
|
||||
this->_addType(this->g);
|
||||
this->_addType(this->h);
|
||||
this->_addType(this->i);
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#include "model.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using namespace sirEdit::data;
|
||||
|
||||
// TODO: Error test!
|
|
@ -0,0 +1,6 @@
|
|||
#include "model.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using namespace sirEdit::data;
|
||||
|
||||
// TODO: Error test!
|
|
@ -0,0 +1,11 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <sirEdit/data/types.hpp>
|
||||
|
||||
using namespace sirEdit::data;
|
||||
|
||||
TEST(rule_3, ReadLowerWrite) {
|
||||
EXPECT_LT(FIELD_STATE::READ, FIELD_STATE::WRITE);
|
||||
}
|
||||
TEST(rule_3, WriteLowerCreate) {
|
||||
EXPECT_LT(FIELD_STATE::WRITE, FIELD_STATE::CREATE);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <sirEdit/data/types.hpp>
|
||||
|
||||
using namespace sirEdit::data;
|
||||
|
||||
TEST(rule_4, ReadLowerWrite) {
|
||||
EXPECT_LT(TYPE_STATE::READ, TYPE_STATE::WRITE);
|
||||
}
|
||||
TEST(rule_4, WriteLowerDelete) {
|
||||
EXPECT_LT(TYPE_STATE::WRITE, TYPE_STATE::DELETE);
|
||||
}
|
Loading…
Reference in New Issue