summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/StreamingMemoryObjectTest.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-03-27 22:55:19 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-03-27 22:55:19 +0000
commit6648a0817ef664d75374b303c1f4abb350576f31 (patch)
tree176dd3a148663d8c4c941cfbd4b9b75bc8cbaa40 /llvm/unittests/Support/StreamingMemoryObjectTest.cpp
parent58c7d4950ab51491e66f1eb7bff4978c71bb7625 (diff)
downloadbcm5719-llvm-6648a0817ef664d75374b303c1f4abb350576f31.tar.gz
bcm5719-llvm-6648a0817ef664d75374b303c1f4abb350576f31.zip
Support: Move StreamingMemoryObject{,Test}.cpp, NFC
Change the filename to indicate this is a test, rename the tests, move them into an anonymous namespace, and rename some variables. All to match our usual style before making further changes. llvm-svn: 264548
Diffstat (limited to 'llvm/unittests/Support/StreamingMemoryObjectTest.cpp')
-rw-r--r--llvm/unittests/Support/StreamingMemoryObjectTest.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/llvm/unittests/Support/StreamingMemoryObjectTest.cpp b/llvm/unittests/Support/StreamingMemoryObjectTest.cpp
new file mode 100644
index 00000000000..261f2144392
--- /dev/null
+++ b/llvm/unittests/Support/StreamingMemoryObjectTest.cpp
@@ -0,0 +1,42 @@
+//===- unittests/Support/StreamingMemoryObjectTest.cpp --------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#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 *Buffer, size_t Length) override {
+ memset(Buffer, 0, Length);
+ return Length;
+ }
+};
+
+TEST(StreamingMemoryObjectTest, isValidAddress) {
+ auto DS = make_unique<NullDataStreamer>();
+ StreamingMemoryObject O(std::move(DS));
+ EXPECT_TRUE(O.isValidAddress(32 * 1024));
+}
+
+TEST(StreamingMemoryObjectTest, setKnownObjectSize) {
+ auto DS = make_unique<NullDataStreamer>();
+ StreamingMemoryObject O(std::move(DS));
+ uint8_t Buf[32];
+ EXPECT_EQ(16u, O.readBytes(Buf, 16, 0));
+ O.setKnownObjectSize(24);
+ EXPECT_EQ(8u, O.readBytes(Buf, 16, 16));
+}
+
+} // end namespace
OpenPOWER on IntegriCloud