ELFBinaryReaderTest.cpp revision 37b74a387bb3993387029859c2d9d051c41c724e
1//===- ELFBinaryReaderTest.cpp --------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#include "mcld/LD/ELFBinaryReader.h" 10#include "mcld/Module.h" 11#include "mcld/LinkerScript.h" 12#include "mcld/LinkerConfig.h" 13#include "mcld/IRBuilder.h" 14#include "mcld/GeneralOptions.h" 15#include "mcld/MC/Input.h" 16 17#include "ELFBinaryReaderTest.h" 18 19using namespace mcld; 20using namespace mcld::test; 21 22// Constructor can do set-up work for all test here. 23ELFBinaryReaderTest::ELFBinaryReaderTest() { 24} 25 26// Destructor can do clean-up work that doesn't throw exceptions here. 27ELFBinaryReaderTest::~ELFBinaryReaderTest() { 28} 29 30// SetUp() will be called immediately before each test. 31void ELFBinaryReaderTest::SetUp() { 32} 33 34// TearDown() will be called immediately after each test. 35void ELFBinaryReaderTest::TearDown() { 36} 37 38//===----------------------------------------------------------------------===// 39// Testcases 40//===----------------------------------------------------------------------===// 41TEST_F(ELFBinaryReaderTest, is_myformat) { 42 LinkerScript script; 43 Module module("test", script); 44 LinkerConfig config; 45 IRBuilder builder(module, config); 46 ELFBinaryReader* reader = new ELFBinaryReader(builder, config); 47 48 Input input("test.bin"); 49 50 bool doContinue = false; 51 config.options().setBinaryInput(); 52 ASSERT_TRUE(reader->isMyFormat(input, doContinue)); 53 54 config.options().setBinaryInput(false); 55 ASSERT_FALSE(reader->isMyFormat(input, doContinue)); 56 57 delete reader; 58} 59