summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/StreamingMemoryObject.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-11-21 05:15:41 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-11-21 05:15:41 +0000
commit945d7f58bde660b2523945962ec98aa258137d6f (patch)
tree348f9016a67fc0b720fef8027956ef0aeed77efa /llvm/unittests/Support/StreamingMemoryObject.cpp
parentf413be11f0df6374d4091114ec81a758a14b4f18 (diff)
downloadbcm5719-llvm-945d7f58bde660b2523945962ec98aa258137d6f.tar.gz
bcm5719-llvm-945d7f58bde660b2523945962ec98aa258137d6f.zip
Fix a silly bug in StreamingMemoryObject.cpp.
The logic for detecting EOF was wrong and would fail if we ever requested more than 16k past the last read position. llvm-svn: 222505
Diffstat (limited to 'llvm/unittests/Support/StreamingMemoryObject.cpp')
-rw-r--r--llvm/unittests/Support/StreamingMemoryObject.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/unittests/Support/StreamingMemoryObject.cpp b/llvm/unittests/Support/StreamingMemoryObject.cpp
new file mode 100644
index 00000000000..399501ed35c
--- /dev/null
+++ b/llvm/unittests/Support/StreamingMemoryObject.cpp
@@ -0,0 +1,30 @@
+//===- llvm/unittest/Support/StreamingMemoryObject.cpp - unit tests -------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/StreamingMemoryObject.h"
+#include "gtest/gtest.h"
+
+#include <string.h>
+
+using namespace llvm;
+
+namespace {
+class NullDataStreamer : public DataStreamer {
+ size_t GetBytes(unsigned char *buf, size_t len) override {
+ memset(buf, 0, len);
+ return len;
+ }
+};
+}
+
+TEST(StreamingMemoryObject, Test) {
+ auto *DS = new NullDataStreamer();
+ StreamingMemoryObject O(DS);
+ EXPECT_TRUE(O.isValidAddress(32 * 1024));
+}
OpenPOWER on IntegriCloud