#include "llvm/ADT/fallible_iterator.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
#include <utility>
#include <vector>
usingnamespacellvm;
namespace {
using ItemValid = enum { … };
using LinkValid = enum { … };
class Item { … };
FallibleCollection;
class FallibleCollectionWalker { … };
class FallibleCollectionWalkerWithStructDeref
: public FallibleCollectionWalker { … };
class FallibleCollectionWalkerWithFallibleDeref
: public FallibleCollectionWalker { … };
TEST(FallibleIteratorTest, BasicSuccess) { … }
TEST(FallibleIteratorTest, BasicFailure) { … }
TEST(FallibleIteratorTest, NoRedundantErrorCheckOnEarlyExit) { … }
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
TEST(FallibleIteratorTest, RegularLoopExitRequiresErrorCheck) {
EXPECT_DEATH(
{
FallibleCollection C({{ValidItem, ValidLink}, {ValidItem, ValidLink}});
FallibleCollectionWalker begin(C, 0);
FallibleCollectionWalker end(C, 2);
Error Err = Error::success();
for (auto &Elem :
make_fallible_range<FallibleCollectionWalker>(begin, end, Err))
(void)Elem;
},
"Program aborted due to an unhandled Error:")
<< "Normal (i.e. not early) loop exit should require an error check";
}
#endif
TEST(FallibleIteratorTest, RawIncrementAndDecrementBehavior) { … }
TEST(FallibleIteratorTest, CheckStructDerefOperatorSupport) { … }
TEST(FallibleIteratorTest, CheckDerefToExpectedSupport) { … }
}