2022-09-30 21:31:22 +00:00
|
|
|
//
|
|
|
|
// Created by moss on 9/30/22.
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "iostream"
|
|
|
|
|
2023-02-05 19:33:25 +00:00
|
|
|
#include "../src/color.h"
|
2022-09-30 21:31:22 +00:00
|
|
|
|
2023-02-05 19:33:25 +00:00
|
|
|
namespace dropout_dl {
|
2022-09-30 21:31:22 +00:00
|
|
|
|
|
|
|
template <typename t> class test {
|
|
|
|
public:
|
|
|
|
std::string name;
|
|
|
|
t result;
|
|
|
|
t expected_result;
|
2022-10-01 03:47:32 +00:00
|
|
|
bool success = false;
|
2022-09-30 21:31:22 +00:00
|
|
|
|
2022-10-01 03:47:32 +00:00
|
|
|
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) {}
|
2022-09-30 21:31:22 +00:00
|
|
|
|
2022-10-01 03:47:32 +00:00
|
|
|
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) {
|
2022-09-30 21:31:22 +00:00
|
|
|
t test_result = function(argument);
|
|
|
|
this->result = test_result;
|
|
|
|
this->success = test_result == expected_result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void display_result();
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class tests {
|
|
|
|
public:
|
|
|
|
std::vector<test<std::string>> tests_vector;
|
|
|
|
std::string name;
|
|
|
|
bool success;
|
|
|
|
|
2022-10-01 03:47:32 +00:00
|
|
|
tests(std::string name, std::vector<test<std::string>> tests) : name(std::move(name)), tests_vector(std::move(tests)) {
|
2022-09-30 21:31:22 +00:00
|
|
|
this->success = tests_vector.front().success;
|
|
|
|
for (const auto& test : tests_vector) {
|
|
|
|
success = success && test.success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void display();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-02-05 19:33:25 +00:00
|
|
|
}
|