Skip to content

Commit 27d2197

Browse files
committed
added unit test
1 parent cc28e55 commit 27d2197

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

llvm/unittests/Object/SymbolicFileTest.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/Object/SymbolicFile.h"
10+
#include "llvm/ADT/STLExtras.h"
1011
#include "llvm/Support/raw_ostream.h"
1112
#include "llvm/TargetParser/Host.h"
13+
1214
#include "gtest/gtest.h"
1315
#include <sstream>
1416

@@ -38,3 +40,24 @@ TEST(Object, DataRefImplOstream) {
3840

3941
EXPECT_EQ(Expected, s);
4042
}
43+
44+
struct ProxyContent {
45+
unsigned Index = 0;
46+
ProxyContent(unsigned Index) : Index(Index) {};
47+
void moveNext() { Index++; }
48+
49+
bool operator==(const ProxyContent &Another) const {
50+
return Index == Another.Index;
51+
}
52+
};
53+
54+
TEST(Object, ContentIterator) {
55+
using Iter = llvm::object::content_iterator<ProxyContent>;
56+
auto Sequence = llvm::make_range(Iter(0u), Iter(10u));
57+
auto EvenSequence = llvm::make_filter_range(
58+
Sequence, [](auto &&PC) { return PC.Index % 2 == 0; });
59+
60+
for (auto &&[I, Value] : llvm::enumerate(EvenSequence)) {
61+
EXPECT_EQ(I * 2u, Value.Index);
62+
}
63+
}

0 commit comments

Comments
 (0)