| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- //
- // all_test.cxx
- // stream-test
- //
- // Created by Sam Jaffe on 4/2/23.
- //
- #include "stream/view/all.h"
- #include "stream_helpers.h"
- #include "stream_matchers.h"
- using testing::Ne;
- TEST(AllView, IteratesOverNonConst) {
- std::vector<int> input{1, 2, 3, 4, 5};
- auto view = views::all(input);
- EXPECT_FALSE(view.empty());
- EXPECT_THAT(view.size(), input.size());
- EXPECT_THAT(view, RangesEq(input));
- }
- TEST(AllView, IteratesOverConst) {
- std::vector<int> const input{1, 2, 3, 4, 5};
- auto view = views::all(input);
- EXPECT_FALSE(view.empty());
- EXPECT_THAT(view.size(), input.size());
- EXPECT_THAT(view, RangesEq(input));
- }
- TEST(AllView, TakesOwnershipOfRvalue) {
- std::vector<int> input{1, 2, 3, 4, 5};
- auto * address = &input;
- auto view = views::all(static_cast<std::vector<int> &&>(input));
- EXPECT_TRUE(input.empty());
- EXPECT_THAT(&view.base(), Ne(address));
- }
- TEST(AllView, IteratesOverRvalue) {
- auto view = views::all(std::vector{1, 2, 3, 4, 5});
- EXPECT_FALSE(view.empty());
- EXPECT_THAT(view.size(), 5);
- EXPECT_THAT(view, RangesEq(std::vector{1, 2, 3, 4, 5}));
- }
|