OSDN Git Service

Support: Move StreamingMemoryObject{,Test}.cpp, NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sun, 27 Mar 2016 22:55:19 +0000 (22:55 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sun, 27 Mar 2016 22:55:19 +0000 (22:55 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264548 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Support/CMakeLists.txt
unittests/Support/StreamingMemoryObjectTest.cpp [moved from unittests/Support/StreamingMemoryObject.cpp with 62% similarity]

index 053ca32..f02d501 100644 (file)
@@ -36,7 +36,7 @@ add_llvm_unittest(SupportTests
   ScaledNumberTest.cpp
   SourceMgrTest.cpp
   SpecialCaseListTest.cpp
-  StreamingMemoryObject.cpp
+  StreamingMemoryObjectTest.cpp
   StringPool.cpp
   SwapByteOrderTest.cpp
   TargetParserTest.cpp
@@ -1,4 +1,4 @@
-//===- llvm/unittest/Support/StreamingMemoryObject.cpp - unit tests -------===//
+//===- unittests/Support/StreamingMemoryObjectTest.cpp --------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #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 *buf, size_t len) override {
-    memset(buf, 0, len);
-    return len;
+  size_t GetBytes(unsigned char *Buffer, size_t Length) override {
+    memset(Buffer, 0, Length);
+    return Length;
   }
 };
-}
 
-TEST(StreamingMemoryObject, Test) {
+TEST(StreamingMemoryObjectTest, isValidAddress) {
   auto DS = make_unique<NullDataStreamer>();
   StreamingMemoryObject O(std::move(DS));
   EXPECT_TRUE(O.isValidAddress(32 * 1024));
 }
 
-TEST(StreamingMemoryObject, TestSetKnownObjectSize) {
+TEST(StreamingMemoryObjectTest, setKnownObjectSize) {
   auto DS = make_unique<NullDataStreamer>();
   StreamingMemoryObject O(std::move(DS));
   uint8_t Buf[32];
-  EXPECT_EQ((uint64_t) 16, O.readBytes(Buf, 16, 0));
+  EXPECT_EQ(16u, O.readBytes(Buf, 16, 0));
   O.setKnownObjectSize(24);
-  EXPECT_EQ((uint64_t) 8, O.readBytes(Buf, 16, 16));
+  EXPECT_EQ(8u, O.readBytes(Buf, 16, 16));
 }
+
+} // end namespace