5 #include <rive/span.hpp>
12 TEST_CASE("basics", "[span]") {
14 REQUIRE(span.empty());
15 REQUIRE(span.size() == 0);
16 REQUIRE(span.size_bytes() == 0);
17 REQUIRE(span.begin() == span.end());
19 int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
22 REQUIRE(!span.empty());
23 REQUIRE(span.data() == array);
24 REQUIRE(span.size() == 4);
25 REQUIRE(span.size_bytes() == 4 * sizeof(int));
26 REQUIRE(span.begin() + span.size() == span.end());
34 REQUIRE(counter == 4);
35 REQUIRE(sum == 0 + 1 + 2 + 3);
37 auto sub = span.subset(1, 2);
38 REQUIRE(!sub.empty());
39 REQUIRE(sub.data() == array + 1);
40 REQUIRE(sub.size() == 2);
42 sub = sub.subset(1, 0);
44 REQUIRE(sub.size() == 0);
47 static void funca(Span<int> span) {}
48 static void funcb(Span<const int> span) {}
50 TEST_CASE("const-and-containers", "[span]") {
51 const int carray[] = {1, 2, 3, 4};
54 int array[] = {1, 2, 3, 4};