mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 18:10:40 +02:00
more testing
This commit is contained in:
parent
151c3ee062
commit
f78a98797f
@ -34,6 +34,15 @@ TEST_CASE("Like vector it can be constructed from size and value") {
|
|||||||
REQUIRE(res[4] == 7);
|
REQUIRE(res[4] == 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Result can be iterated using modern syntax"){
|
||||||
|
Result<int> res{0,1,2,3,4,5};
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (const auto& r:res)
|
||||||
|
REQUIRE(r == i++);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("Calling squash on an empty Result produces default value") {
|
TEST_CASE("Calling squash on an empty Result produces default value") {
|
||||||
Result<double> res;
|
Result<double> res;
|
||||||
REQUIRE(res.squash() == 0.);
|
REQUIRE(res.squash() == 0.);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type trait to check if atemplate parameter is a std::chrono::duration
|
* Type trait to check if a template parameter is a std::chrono::duration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <typename T, typename _ = void>
|
template <typename T, typename _ = void>
|
||||||
@ -22,6 +22,19 @@ struct is_duration<T,
|
|||||||
decltype(std::declval<T>().zero())>,
|
decltype(std::declval<T>().zero())>,
|
||||||
void>::type> : public std::true_type {};
|
void>::type> : public std::true_type {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Has str method
|
||||||
|
*/
|
||||||
|
template <typename T, typename _ = void> struct has_str : std::false_type {};
|
||||||
|
|
||||||
|
template <typename... Ts> struct has_str_helper {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct has_str<T, typename std::conditional<
|
||||||
|
false,
|
||||||
|
has_str_helper<decltype(std::declval<T>().str())>,
|
||||||
|
void>::type> : public std::true_type {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type trait to evaluate if template parameter is
|
* Type trait to evaluate if template parameter is
|
||||||
* complying with a standard container
|
* complying with a standard container
|
||||||
|
@ -1,10 +1,41 @@
|
|||||||
#include "catch.hpp"
|
|
||||||
#include "TypeTraits.h"
|
#include "TypeTraits.h"
|
||||||
#include <vector>
|
#include "catch.hpp"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
TEST_CASE("something", "[n3]"){
|
//Dummy classes only used here for testing
|
||||||
|
class DummyWithStr {
|
||||||
|
public:
|
||||||
|
std::string str();
|
||||||
|
};
|
||||||
|
|
||||||
|
class DummyNoStr {
|
||||||
|
public:
|
||||||
|
std::string somethingelse();
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE("sls::is_container") {
|
||||||
|
|
||||||
CHECK(sls::is_container<std::vector<int>>::value == true);
|
CHECK(sls::is_container<std::vector<int>>::value == true);
|
||||||
CHECK(sls::is_container<std::array<double, 3>>::value == true);
|
CHECK(sls::is_container<std::array<double, 3>>::value == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Check for str() method") {
|
||||||
|
REQUIRE(sls::has_str<DummyWithStr>::value == true);
|
||||||
|
REQUIRE(sls::has_str<DummyNoStr>::value == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Check for str() on ostream") {
|
||||||
|
REQUIRE(sls::has_str<std::ostringstream>::value == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("sls::is_duration"){
|
||||||
|
REQUIRE(sls::is_duration<std::chrono::nanoseconds>::value == true);
|
||||||
|
REQUIRE(sls::is_duration<std::chrono::seconds>::value == true);
|
||||||
|
REQUIRE(sls::is_duration<std::chrono::hours>::value == true);
|
||||||
|
|
||||||
|
REQUIRE(sls::is_duration<int>::value == false);
|
||||||
|
REQUIRE(sls::is_duration<std::vector<int>>::value == false);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user