Initial Course
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#include "span.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(Span, SpanSum) {
|
||||
const int data[] = {1, 2, 3, 4};
|
||||
EXPECT_EQ(cpp20::span_sum(data), 10);
|
||||
}
|
||||
|
||||
TEST(Span, FirstAndLast) {
|
||||
const std::vector<int> data = {10, 20, 30};
|
||||
const auto [first, last] = cpp20::first_and_last(std::span<const int>{data});
|
||||
EXPECT_EQ(first, 10);
|
||||
EXPECT_EQ(last, 30);
|
||||
}
|
||||
|
||||
TEST(Span, MakeSubspan) {
|
||||
const std::vector<int> data = {1, 2, 3, 4, 5};
|
||||
EXPECT_EQ(cpp20::make_subspan(data, 1, 3), (std::vector<int>{2, 3, 4}));
|
||||
}
|
||||
Reference in New Issue
Block a user