Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Jan 27, 2025
1 parent 7b923dc commit 406a96d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/xtd.core.unit_tests/src/xtd/tests/span_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,5 +446,44 @@ namespace xtd::tests {
assert::are_equal(a.data(), s.data());
assert::are_equal(10, *s.data());
}

void test_method_(empty) {
auto a = array {10, 20, 30, 40, 50};
auto s = span(a);
assert::is_false(s.empty());
assert::is_true(span<int> {}.empty());
assert::is_true(span<int>::empty_span.empty());
}

void test_method_(empty_span) {
assert::is_null(span<int>::empty_span.data());
assert::is_zero(span<int>::empty_span.size());
}

void test_method_(const_end) {
auto a = array {10, 20, 30, 40, 50};
const auto s = span(a);
assert::are_equal(s.data() + 5, s.end().data());
}

void test_method_(end) {
auto a = array {10, 20, 30, 40, 50};
auto s = span(a);
assert::are_equal(s.data() + 5, s.end().data());
}

void test_method_(front) {
auto a = array {10, 20, 30, 40, 50};
auto s = span(a);
assert::are_equal(10, s.front());
}

void test_method_(is_empty) {
auto a = array {10, 20, 30, 40, 50};
auto s = span(a);
assert::is_false(s.is_empty());
assert::is_true(span<int> {}.is_empty());
assert::is_true(span<int>::empty_span.is_empty());
}
};
}

0 comments on commit 406a96d

Please sign in to comment.