[llvm] r264548 - Support: Move StreamingMemoryObject{,Test}.cpp, NFC

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 27 15:55:19 PDT 2016


Author: dexonsmith
Date: Sun Mar 27 17:55:19 2016
New Revision: 264548

URL: http://llvm.org/viewvc/llvm-project?rev=264548&view=rev
Log:
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.

Added:
    llvm/trunk/unittests/Support/StreamingMemoryObjectTest.cpp
      - copied, changed from r264547, llvm/trunk/unittests/Support/StreamingMemoryObject.cpp
Removed:
    llvm/trunk/unittests/Support/StreamingMemoryObject.cpp
Modified:
    llvm/trunk/unittests/Support/CMakeLists.txt

Modified: llvm/trunk/unittests/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/CMakeLists.txt?rev=264548&r1=264547&r2=264548&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/CMakeLists.txt (original)
+++ llvm/trunk/unittests/Support/CMakeLists.txt Sun Mar 27 17:55:19 2016
@@ -36,7 +36,7 @@ add_llvm_unittest(SupportTests
   ScaledNumberTest.cpp
   SourceMgrTest.cpp
   SpecialCaseListTest.cpp
-  StreamingMemoryObject.cpp
+  StreamingMemoryObjectTest.cpp
   StringPool.cpp
   SwapByteOrderTest.cpp
   TargetParserTest.cpp

Removed: llvm/trunk/unittests/Support/StreamingMemoryObject.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/StreamingMemoryObject.cpp?rev=264547&view=auto
==============================================================================
--- llvm/trunk/unittests/Support/StreamingMemoryObject.cpp (original)
+++ llvm/trunk/unittests/Support/StreamingMemoryObject.cpp (removed)
@@ -1,39 +0,0 @@
-//===- 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/ADT/STLExtras.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;
-  }
-};
-}
-
-TEST(StreamingMemoryObject, Test) {
-  auto DS = make_unique<NullDataStreamer>();
-  StreamingMemoryObject O(std::move(DS));
-  EXPECT_TRUE(O.isValidAddress(32 * 1024));
-}
-
-TEST(StreamingMemoryObject, TestSetKnownObjectSize) {
-  auto DS = make_unique<NullDataStreamer>();
-  StreamingMemoryObject O(std::move(DS));
-  uint8_t Buf[32];
-  EXPECT_EQ((uint64_t) 16, O.readBytes(Buf, 16, 0));
-  O.setKnownObjectSize(24);
-  EXPECT_EQ((uint64_t) 8, O.readBytes(Buf, 16, 16));
-}

Copied: llvm/trunk/unittests/Support/StreamingMemoryObjectTest.cpp (from r264547, llvm/trunk/unittests/Support/StreamingMemoryObject.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/StreamingMemoryObjectTest.cpp?p2=llvm/trunk/unittests/Support/StreamingMemoryObjectTest.cpp&p1=llvm/trunk/unittests/Support/StreamingMemoryObject.cpp&r1=264547&r2=264548&rev=264548&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/StreamingMemoryObject.cpp (original)
+++ llvm/trunk/unittests/Support/StreamingMemoryObjectTest.cpp Sun Mar 27 17:55:19 2016
@@ -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>
@@ -15,25 +16,27 @@
 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




More information about the llvm-commits mailing list