Index: llvm/trunk/unittests/Support/BinaryStreamTest.cpp =================================================================== --- llvm/trunk/unittests/Support/BinaryStreamTest.cpp +++ llvm/trunk/unittests/Support/BinaryStreamTest.cpp @@ -16,6 +16,7 @@ #include "gtest/gtest.h" #include +#include using namespace llvm; using namespace llvm::support; @@ -117,7 +118,7 @@ // Buffer is organized like this: // ------------------------------------------------- - // | N/2 | N/2+1 | ... | N-1 | 0 | 1 | ... | N-2-1 | + // | N/2 | N/2+1 | ... | N-1 | 0 | 1 | ... | N/2-1 | // ------------------------------------------------- // So reads from the beginning actually come from the middle. MutableArrayRef Data; @@ -348,6 +349,30 @@ } } +// Ensure FixedStreamArrayIterator::operator-> works. +// Added for coverage of r302257. +TEST_F(BinaryStreamTest, FixedStreamArrayIteratorArrow) { + std::vector> Pairs = {{867, 5309}, {555, 1212}}; + ArrayRef PairBytes(reinterpret_cast(Pairs.data()), + Pairs.size() * sizeof(Pairs[0])); + + initializeInput(PairBytes, alignof(uint32_t)); + + for (auto &Stream : Streams) { + ASSERT_EQ(InputData.size(), Stream.Input->getLength()); + + const FixedStreamArray> Array(*Stream.Input); + auto Iter = Array.begin(); + ASSERT_EQ(Pairs[0].first, Iter->first); + ASSERT_EQ(Pairs[0].second, Iter->second); + ++Iter; + ASSERT_EQ(Pairs[1].first, Iter->first); + ASSERT_EQ(Pairs[1].second, Iter->second); + ++Iter; + ASSERT_EQ(Array.end(), Iter); + } +} + // Test that VarStreamArray works correctly. TEST_F(BinaryStreamTest, VarStreamArray) { StringLiteral Strings("1. Test2. Longer Test3. Really Long Test4. Super " @@ -686,7 +711,7 @@ std::vector Foos = {{1, 1.0}, {2, 2.0}, {3, 3.0}}; BumpPtrAllocator Allocator; for (const auto &F : Foos) { - uint8_t *Ptr = static_cast(Allocator.Allocate(sizeof(Foo), + uint8_t *Ptr = static_cast(Allocator.Allocate(sizeof(Foo), alignof(Foo))); MutableArrayRef Buffer(Ptr, sizeof(Foo)); MutableBinaryByteStream Stream(Buffer, llvm::support::big);