mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 02:25:19 +00:00
Start MCAsmStreamer implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74044 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
52
unittests/MC/AsmStreamerTest.cpp
Normal file
52
unittests/MC/AsmStreamerTest.cpp
Normal file
@@ -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");
|
||||
}
|
||||
|
||||
}
|
15
unittests/MC/Makefile
Normal file
15
unittests/MC/Makefile
Normal file
@@ -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
|
@@ -16,7 +16,7 @@ BUILD_ARCHIVE = 1
|
||||
CPP.Flags += -I$(LLVM_SRC_ROOT)/utils/unittest/googletest/include/
|
||||
CPP.Flags += -Wno-variadic-macros
|
||||
|
||||
PARALLEL_DIRS = ADT Support VMCore
|
||||
PARALLEL_DIRS = ADT Support VMCore MC
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
|
Reference in New Issue
Block a user