Tests: Updated Constructor Syntax
This commit is contained in:
parent
d70e2973de
commit
d0989e4b6b
17
tests/test.h
17
tests/test.h
|
@ -38,20 +38,13 @@ namespace dropout_dl {
|
||||||
std::string name;
|
std::string name;
|
||||||
t result;
|
t result;
|
||||||
t expected_result;
|
t expected_result;
|
||||||
bool success;
|
bool success = false;
|
||||||
|
|
||||||
test(const std::string& name, const t& result, const t& expected_result) {
|
test(std::string name, const t& result, const t& expected_result) : name(std::move(name)), result(result), expected_result(expected_result), success(result == expected_result) {}
|
||||||
this->name = name;
|
|
||||||
this->result = result;
|
|
||||||
this->expected_result = expected_result;
|
|
||||||
this->success = (result == expected_result);
|
|
||||||
}
|
|
||||||
|
|
||||||
test(const std::string& test_name, t (*function)(const t &), const t &argument, const t& expected_result) {
|
test(std::string test_name, t (*function)(const t &), const t &argument, const t& expected_result) : name(std::move(test_name)), expected_result(expected_result) {
|
||||||
t test_result = function(argument);
|
t test_result = function(argument);
|
||||||
this->name = test_name;
|
|
||||||
this->result = test_result;
|
this->result = test_result;
|
||||||
this->expected_result = expected_result;
|
|
||||||
this->success = test_result == expected_result;
|
this->success = test_result == expected_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +60,7 @@ namespace dropout_dl {
|
||||||
std::string name;
|
std::string name;
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
tests(const std::string& name, const std::vector<test<std::string>>& tests) {
|
tests(std::string name, std::vector<test<std::string>> tests) : name(std::move(name)), tests_vector(std::move(tests)) {
|
||||||
this->name = name;
|
|
||||||
this->tests_vector = tests;
|
|
||||||
this->success = tests_vector.front().success;
|
this->success = tests_vector.front().success;
|
||||||
for (const auto& test : tests_vector) {
|
for (const auto& test : tests_vector) {
|
||||||
success = success && test.success;
|
success = success && test.success;
|
||||||
|
|
Loading…
Reference in New Issue