-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fd3a79
commit 81be0d5
Showing
4 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <frozen/array.h> | ||
|
||
#include "bench.hpp" | ||
#include "catch.hpp" | ||
|
||
/* | ||
TEST_CASE("empty frozen array", "[array]") { | ||
constexpr frozen::array<int, 0> ze_array{}; | ||
constexpr auto empty = ze_array.empty(); | ||
REQUIRE(empty); | ||
constexpr auto size = ze_array.size(); | ||
REQUIRE(size == 0); | ||
constexpr auto max_size = ze_array.max_size(); | ||
REQUIRE(max_size == 0); | ||
constexpr auto capacity = ze_array.capacity(); | ||
REQUIRE(capacity == 0); | ||
auto constexpr begin = ze_array.begin(), end = ze_array.end(); | ||
REQUIRE(begin == end); | ||
auto constexpr cbegin = ze_array.cbegin(), cend = ze_array.cend(); | ||
REQUIRE(cbegin == cend); | ||
std::for_each(ze_array.begin(), ze_array.end(), [](int) {}); | ||
REQUIRE(std::distance(ze_array.rbegin(), ze_array.rend()) == 0); | ||
REQUIRE(std::count(ze_array.crbegin(), ze_array.crend(), 3) == 0); | ||
} | ||
*/ | ||
|
||
TEST_CASE("singleton frozen array", "[array]") { | ||
constexpr frozen::array<short, 1> ze_array{1}; | ||
|
||
constexpr auto empty = ze_array.empty(); | ||
REQUIRE(!empty); | ||
|
||
constexpr auto size = ze_array.size(); | ||
REQUIRE(size == 1); | ||
|
||
constexpr auto max_size = ze_array.max_size(); | ||
REQUIRE(max_size == 1); | ||
|
||
const auto value_op = ze_array[0]; | ||
REQUIRE(value_op == 1); | ||
|
||
const auto value_at = ze_array.at(0); | ||
REQUIRE(value_at == 1); | ||
|
||
auto const begin = ze_array.begin(), end = ze_array.end(); | ||
REQUIRE((begin + 1) == end); | ||
|
||
auto const cbegin = ze_array.cbegin(), cend = ze_array.cend(); | ||
REQUIRE(cbegin == (cend - 1)); | ||
|
||
std::for_each(ze_array.begin(), ze_array.end(), [](int) {}); | ||
REQUIRE(std::distance(ze_array.rbegin(), ze_array.rend()) == 1); | ||
REQUIRE(std::count(ze_array.crbegin(), ze_array.crend(), 3) == 0); | ||
REQUIRE(std::count(ze_array.crbegin(), ze_array.crend(), 1) == 1); | ||
} | ||
|
||
TEST_CASE("array from array", "[array]") { | ||
constexpr short data[4]{1, 2, 3, 4}; | ||
constexpr frozen::array<short, 4> ze_array(data); | ||
|
||
constexpr auto value = ze_array[2]; | ||
REQUIRE(value == 3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#include <frozen/vector.h> | ||
|
||
#include "bench.hpp" | ||
#include "catch.hpp" | ||
|
||
/* | ||
TEST_CASE("empty frozen vector", "[vector]") { | ||
constexpr frozen::vector<int, 0> ze_vector{}; | ||
constexpr auto empty = ze_vector.empty(); | ||
REQUIRE(empty); | ||
constexpr auto size = ze_vector.size(); | ||
REQUIRE(size == 0); | ||
constexpr auto max_size = ze_vector.max_size(); | ||
REQUIRE(max_size == 0); | ||
constexpr auto capacity = ze_vector.capacity(); | ||
REQUIRE(capacity == 0); | ||
auto constexpr begin = ze_vector.begin(), end = ze_vector.end(); | ||
REQUIRE(begin == end); | ||
auto constexpr cbegin = ze_vector.cbegin(), cend = ze_vector.cend(); | ||
REQUIRE(cbegin == cend); | ||
std::for_each(ze_vector.begin(), ze_vector.end(), [](int) {}); | ||
REQUIRE(std::distance(ze_vector.rbegin(), ze_vector.rend()) == 0); | ||
REQUIRE(std::count(ze_vector.crbegin(), ze_vector.crend(), 3) == 0); | ||
} | ||
*/ | ||
|
||
TEST_CASE("singleton frozen vector", "[vector]") { | ||
constexpr frozen::vector<short, 1> ze_vector{1}; | ||
|
||
constexpr auto empty = ze_vector.empty(); | ||
REQUIRE(!empty); | ||
|
||
constexpr auto size = ze_vector.size(); | ||
REQUIRE(size == 1); | ||
|
||
constexpr auto max_size = ze_vector.max_size(); | ||
REQUIRE(max_size == 1); | ||
|
||
constexpr auto capacity = ze_vector.capacity(); | ||
REQUIRE(capacity == 1); | ||
|
||
const auto value_op = ze_vector[0]; | ||
REQUIRE(value_op == 1); | ||
|
||
const auto value_at = ze_vector.at(0); | ||
REQUIRE(value_at == 1); | ||
|
||
auto const begin = ze_vector.begin(), end = ze_vector.end(); | ||
REQUIRE((begin + 1) == end); | ||
|
||
auto const cbegin = ze_vector.cbegin(), cend = ze_vector.cend(); | ||
REQUIRE(cbegin == (cend - 1)); | ||
|
||
std::for_each(ze_vector.begin(), ze_vector.end(), [](int) {}); | ||
REQUIRE(std::distance(ze_vector.rbegin(), ze_vector.rend()) == 1); | ||
REQUIRE(std::count(ze_vector.crbegin(), ze_vector.crend(), 3) == 0); | ||
REQUIRE(std::count(ze_vector.crbegin(), ze_vector.crend(), 1) == 1); | ||
} | ||
|
||
TEST_CASE("non-full frozen vector", "[vector]") { | ||
constexpr frozen::vector<short, 4> ze_vector{1}; | ||
|
||
constexpr auto empty = ze_vector.empty(); | ||
REQUIRE(!empty); | ||
|
||
constexpr auto size = ze_vector.size(); | ||
REQUIRE(size == 1); | ||
|
||
constexpr auto max_size = ze_vector.max_size(); | ||
REQUIRE(max_size == 4); | ||
|
||
constexpr auto capacity = ze_vector.capacity(); | ||
REQUIRE(capacity == 4); | ||
|
||
const auto value_op = ze_vector[0]; | ||
REQUIRE(value_op == 1); | ||
|
||
const auto value_at = ze_vector.at(0); | ||
REQUIRE(value_at == 1); | ||
|
||
auto const begin = ze_vector.begin(), end = ze_vector.end(); | ||
REQUIRE((begin + 1) == end); | ||
|
||
auto const cbegin = ze_vector.cbegin(), cend = ze_vector.cend(); | ||
REQUIRE(cbegin == (cend - 1)); | ||
|
||
std::for_each(ze_vector.begin(), ze_vector.end(), [](int) {}); | ||
REQUIRE(std::distance(ze_vector.rbegin(), ze_vector.rend()) == 1); | ||
REQUIRE(std::count(ze_vector.crbegin(), ze_vector.crend(), 3) == 0); | ||
REQUIRE(std::count(ze_vector.crbegin(), ze_vector.crend(), 1) == 1); | ||
} | ||
|
||
TEST_CASE("vector from array", "[vector]") { | ||
constexpr short data1[4]{1, 2, 3, 4}; | ||
constexpr frozen::vector<short, 4> ze_vector1(data1); | ||
|
||
constexpr auto value1 = ze_vector1[2]; | ||
REQUIRE(value1 == 3); | ||
|
||
constexpr short data2[3]{1, 2, 3}; | ||
constexpr frozen::vector<short, 4> ze_vector2(data2); | ||
|
||
constexpr auto value2 = ze_vector2[2]; | ||
REQUIRE(value2 == 3); | ||
} |