From 6648a0817ef664d75374b303c1f4abb350576f31 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sun, 27 Mar 2016 22:55:19 +0000 Subject: [PATCH] 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 --- llvm/unittests/Support/CMakeLists.txt | 2 +- ...moryObject.cpp => StreamingMemoryObjectTest.cpp} | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) rename llvm/unittests/Support/{StreamingMemoryObject.cpp => StreamingMemoryObjectTest.cpp} (62%) diff --git a/llvm/unittests/Support/CMakeLists.txt b/llvm/unittests/Support/CMakeLists.txt index 053ca32..f02d501 100644 --- a/llvm/unittests/Support/CMakeLists.txt +++ b/llvm/unittests/Support/CMakeLists.txt @@ -36,7 +36,7 @@ add_llvm_unittest(SupportTests ScaledNumberTest.cpp SourceMgrTest.cpp SpecialCaseListTest.cpp - StreamingMemoryObject.cpp + StreamingMemoryObjectTest.cpp StringPool.cpp SwapByteOrderTest.cpp TargetParserTest.cpp diff --git a/llvm/unittests/Support/StreamingMemoryObject.cpp b/llvm/unittests/Support/StreamingMemoryObjectTest.cpp similarity index 62% rename from llvm/unittests/Support/StreamingMemoryObject.cpp rename to llvm/unittests/Support/StreamingMemoryObjectTest.cpp index e86aa9c..261f214 100644 --- a/llvm/unittests/Support/StreamingMemoryObject.cpp +++ b/llvm/unittests/Support/StreamingMemoryObjectTest.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 @@ -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(); StreamingMemoryObject O(std::move(DS)); EXPECT_TRUE(O.isValidAddress(32 * 1024)); } -TEST(StreamingMemoryObject, TestSetKnownObjectSize) { +TEST(StreamingMemoryObjectTest, setKnownObjectSize) { auto DS = make_unique(); 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 -- 2.7.4