aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/MC
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-24 01:03:06 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-24 01:03:06 +0000
commita11af531ec48ad84f790b9511f003ac5c934a999 (patch)
tree263ca3827523dda5ae497739709ca967f38c08ba /unittests/MC
parentfd6325cbb23935a9c05b96e9bbfa978565029f2a (diff)
downloadexternal_llvm-a11af531ec48ad84f790b9511f003ac5c934a999.zip
external_llvm-a11af531ec48ad84f790b9511f003ac5c934a999.tar.gz
external_llvm-a11af531ec48ad84f790b9511f003ac5c934a999.tar.bz2
Start MCAsmStreamer implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74044 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/MC')
-rw-r--r--unittests/MC/AsmStreamerTest.cpp52
-rw-r--r--unittests/MC/Makefile15
2 files changed, 67 insertions, 0 deletions
diff --git a/unittests/MC/AsmStreamerTest.cpp b/unittests/MC/AsmStreamerTest.cpp
new file mode 100644
index 0000000..80cd456
--- /dev/null
+++ b/unittests/MC/AsmStreamerTest.cpp
@@ -0,0 +1,52 @@
+//===- AsmStreamerTest.cpp - Triple unit tests ----------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "gtest/gtest.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCStreamer.h"
+#include "llvm/Support/raw_ostream.h"
+using namespace llvm;
+
+namespace {
+
+// Helper class.
+class StringAsmStreamer {
+ std::string Str;
+ raw_string_ostream OS;
+ MCContext Context;
+ MCStreamer *Streamer;
+
+public:
+ StringAsmStreamer() : OS(Str), Streamer(createAsmStreamer(Context, OS)) {}
+ ~StringAsmStreamer() {
+ delete Streamer;
+ }
+
+ MCContext &getContext() { return Context; }
+ MCStreamer &getStreamer() { return *Streamer; }
+
+ const std::string &getString() {
+ Streamer->Finish();
+ return Str;
+ }
+};
+
+TEST(AsmStreamer, EmptyOutput) {
+ StringAsmStreamer S;
+ EXPECT_EQ(S.getString(), "");
+}
+
+TEST(AsmStreamer, Sections) {
+ StringAsmStreamer S;
+ MCSection *Sec0 = S.getContext().GetSection("foo");
+ S.getStreamer().SwitchSection(Sec0);
+ EXPECT_EQ(S.getString(), ".section foo\n");
+}
+
+}
diff --git a/unittests/MC/Makefile b/unittests/MC/Makefile
new file mode 100644
index 0000000..410d386
--- /dev/null
+++ b/unittests/MC/Makefile
@@ -0,0 +1,15 @@
+##===- unittests/MC/Makefile -------------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LEVEL = ../..
+TESTNAME = MC
+LINK_COMPONENTS := core support mc
+
+include $(LEVEL)/Makefile.config
+include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest