1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00
llvm-mirror/unittests/IR/DebugInfoTest.cpp
Aaron Ballman be2dcb8639 Silence a -Wcast-qual warning; NFC.
llvm-svn: 220300
2014-10-21 16:12:37 +00:00

69 lines
2.4 KiB
C++

//===- llvm/unittest/IR/DebugInfo.cpp - DebugInfo tests -------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/DebugInfo.h"
#include "gtest/gtest.h"
using namespace llvm;
namespace llvm {
static void PrintTo(const StringRef &S, ::std::ostream *os) {
*os << "(" << (const void *)S.data() << "," << S.size() << ") = '";
for (auto C : S)
if (C)
*os << C;
else
*os << "\\00";
*os << "'";
}
static void PrintTo(const DIHeaderFieldIterator &I, ::std::ostream *os) {
PrintTo(I.getCurrent(), os);
*os << " in ";
PrintTo(I.getHeader(), os);
}
} // end namespace llvm
namespace {
#define MAKE_FIELD_ITERATOR(S) \
DIHeaderFieldIterator(StringRef(S, sizeof(S) - 1))
TEST(DebugInfoTest, DIHeaderFieldIterator) {
ASSERT_EQ(DIHeaderFieldIterator(), DIHeaderFieldIterator());
ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR(""));
ASSERT_EQ(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR(""));
ASSERT_EQ("", *DIHeaderFieldIterator(""));
ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("stuff"));
ASSERT_EQ(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("stuff"));
ASSERT_EQ("stuff", *DIHeaderFieldIterator("stuff"));
ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("st\0uff"));
ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("st\0uff"));
ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("st\0uff"));
ASSERT_EQ("st", *MAKE_FIELD_ITERATOR("st\0uff"));
ASSERT_EQ("uff", *++MAKE_FIELD_ITERATOR("st\0uff"));
ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("stuff\0"));
ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("stuff\0"));
ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("stuff\0"));
ASSERT_EQ("stuff", *MAKE_FIELD_ITERATOR("stuff\0"));
ASSERT_EQ("", *++MAKE_FIELD_ITERATOR("stuff\0"));
ASSERT_NE(DIHeaderFieldIterator(), MAKE_FIELD_ITERATOR("\0stuff"));
ASSERT_NE(DIHeaderFieldIterator(), ++MAKE_FIELD_ITERATOR("\0stuff"));
ASSERT_EQ(DIHeaderFieldIterator(), ++++MAKE_FIELD_ITERATOR("\0stuff"));
ASSERT_EQ("", *MAKE_FIELD_ITERATOR("\0stuff"));
ASSERT_EQ("stuff", *++MAKE_FIELD_ITERATOR("\0stuff"));
}
} // end namespace