diff options
-rw-r--r-- | lldb/include/lldb/Target/MemoryRegionInfo.h | 21 | ||||
-rw-r--r-- | lldb/unittests/Target/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lldb/unittests/Target/MemoryRegionInfoTest.cpp | 20 |
3 files changed, 42 insertions, 0 deletions
diff --git a/lldb/include/lldb/Target/MemoryRegionInfo.h b/lldb/include/lldb/Target/MemoryRegionInfo.h index 8fca15bc800..0824b2442ac 100644 --- a/lldb/include/lldb/Target/MemoryRegionInfo.h +++ b/lldb/include/lldb/Target/MemoryRegionInfo.h @@ -12,6 +12,7 @@ #define lldb_MemoryRegionInfo_h #include "lldb/Core/RangeMap.h" +#include "llvm/Support/FormatProviders.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Range.h" @@ -100,4 +101,24 @@ protected: }; } +namespace llvm { +template <> +struct format_provider<lldb_private::MemoryRegionInfo::OptionalBool> { + static void format(const lldb_private::MemoryRegionInfo::OptionalBool &B, + raw_ostream &OS, StringRef Options) { + switch(B) { + case lldb_private::MemoryRegionInfo::eNo: + OS << "no"; + return; + case lldb_private::MemoryRegionInfo::eYes: + OS << "yes"; + return; + case lldb_private::MemoryRegionInfo::eDontKnow: + OS << "don't know"; + return; + } + } +}; +} + #endif // #ifndef lldb_MemoryRegionInfo_h diff --git a/lldb/unittests/Target/CMakeLists.txt b/lldb/unittests/Target/CMakeLists.txt index c4ad2207d03..e4f6e52b063 100644 --- a/lldb/unittests/Target/CMakeLists.txt +++ b/lldb/unittests/Target/CMakeLists.txt @@ -1,4 +1,5 @@ add_lldb_unittest(TargetTests + MemoryRegionInfoTest.cpp ModuleCacheTest.cpp LINK_LIBS diff --git a/lldb/unittests/Target/MemoryRegionInfoTest.cpp b/lldb/unittests/Target/MemoryRegionInfoTest.cpp new file mode 100644 index 00000000000..704f7f8c48c --- /dev/null +++ b/lldb/unittests/Target/MemoryRegionInfoTest.cpp @@ -0,0 +1,20 @@ +//===-- MemoryRegionInfoTest.cpp --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Target/MemoryRegionInfo.h" +#include "llvm/Support/FormatVariadic.h" +#include "gtest/gtest.h" + +using namespace lldb_private; + +TEST(MemoryRegionInfoTest, Formatv) { + EXPECT_EQ("yes", llvm::formatv("{0}", MemoryRegionInfo::eYes).str()); + EXPECT_EQ("no", llvm::formatv("{0}", MemoryRegionInfo::eNo).str()); + EXPECT_EQ("don't know", llvm::formatv("{0}", MemoryRegionInfo::eDontKnow).str()); +} |