55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
#include "fesa/property/ShellProperty.hpp"
|
|
#include "fesa/property/Property.hpp"
|
|
|
|
#include <stdexcept>
|
|
|
|
namespace {
|
|
|
|
int require(bool condition) {
|
|
return condition ? 0 : 1;
|
|
}
|
|
|
|
template <typename Exception, typename Function>
|
|
int require_throws(Function&& function) {
|
|
try {
|
|
function();
|
|
} catch (const Exception&) {
|
|
return 0;
|
|
} catch (...) {
|
|
return 1;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int run_shell_property_tests() {
|
|
const fesa::property::ShellProperty property{500, 700, 0.01};
|
|
const fesa::property::Property& base = property;
|
|
|
|
if (const int result = require(property.id() == 500); result != 0) {
|
|
return result;
|
|
}
|
|
if (const int result = require(base.id() == 500); result != 0) {
|
|
return result;
|
|
}
|
|
if (const int result = require(base.kind() == fesa::property::PropertyKind::Shell); result != 0) {
|
|
return result;
|
|
}
|
|
if (const int result = require(property.materialId() == 700); result != 0) {
|
|
return result;
|
|
}
|
|
if (const int result = require(property.thickness() == 0.01); result != 0) {
|
|
return result;
|
|
}
|
|
if (const int result = require_throws<std::invalid_argument>([]() {
|
|
(void)fesa::property::ShellProperty{501, 700, 0.0};
|
|
});
|
|
result != 0) {
|
|
return result;
|
|
}
|
|
return require_throws<std::invalid_argument>([]() {
|
|
(void)fesa::property::ShellProperty{502, 700, -0.01};
|
|
});
|
|
}
|