Nttp support

Closes #1531
This commit is contained in:
Jozef Grajciar
2019-04-17 20:23:24 +02:00
parent bd703dd74b
commit 0c43f98fa2
7 changed files with 409 additions and 134 deletions

View File

@@ -18,6 +18,7 @@
#include <cerrno>
#include <limits>
#include <sstream>
#include <array>
namespace { namespace MiscTests {
@@ -66,6 +67,10 @@ struct Foo {
size_t size() { return 0; }
};
template<typename T, size_t S>
struct Bar {
size_t size() { return S; }
};
#endif
TEST_CASE( "random SECTION tests", "[.][sections][failing]" ) {
@@ -306,11 +311,56 @@ TEMPLATE_TEST_CASE( "TemplateTest: vectors can be sized and resized", "[vector][
}
}
TEMPLATE_TEST_CASE_SIG("TemplateTestSig: vectors can be sized and resized", "[vector][template][nttp]", ((typename TestType, int V), TestType, V), (int,5), (float,4), (std::string,15), ((std::tuple<int, float>), 6)) {
std::vector<TestType> v(V);
REQUIRE(v.size() == V);
REQUIRE(v.capacity() >= V);
SECTION("resizing bigger changes size and capacity") {
v.resize(2 * V);
REQUIRE(v.size() == 2 * V);
REQUIRE(v.capacity() >= 2 * V);
}
SECTION("resizing smaller changes size but not capacity") {
v.resize(0);
REQUIRE(v.size() == 0);
REQUIRE(v.capacity() >= V);
SECTION("We can use the 'swap trick' to reset the capacity") {
std::vector<TestType> empty;
empty.swap(v);
REQUIRE(v.capacity() == 0);
}
}
SECTION("reserving bigger changes capacity but not size") {
v.reserve(2 * V);
REQUIRE(v.size() == V);
REQUIRE(v.capacity() >= 2 * V);
}
SECTION("reserving smaller does not change size or capacity") {
v.reserve(0);
REQUIRE(v.size() == V);
REQUIRE(v.capacity() >= V);
}
}
TEMPLATE_PRODUCT_TEST_CASE("A Template product test case", "[template][product]", (std::vector, Foo), (int, float)) {
TestType x;
REQUIRE(x.size() == 0);
}
TEMPLATE_PRODUCT_TEST_CASE_SIG("A Template product test case with array signature", "[template][product][nttp]", ((typename T, size_t S), T, S), (std::array, Bar), ((int, 9), (float, 42))) {
TestType x;
REQUIRE(x.size() > 0);
}
TEMPLATE_PRODUCT_TEST_CASE("Product with differing arities", "[template][product]", std::tuple, (int, (int, double), (int, double, float))) {
REQUIRE(std::tuple_size<TestType>::value >= 1);
}