Home | History | Annotate | Download | only in unittests
      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 
     19 using namespace mcld;
     20 using namespace mcld::test;
     21 
     22 
     23 // Constructor can do set-up work for all test here.
     24 ELFBinaryReaderTest::ELFBinaryReaderTest()
     25 {
     26 }
     27 
     28 // Destructor can do clean-up work that doesn't throw exceptions here.
     29 ELFBinaryReaderTest::~ELFBinaryReaderTest()
     30 {
     31 }
     32 
     33 // SetUp() will be called immediately before each test.
     34 void ELFBinaryReaderTest::SetUp()
     35 {
     36 }
     37 
     38 // TearDown() will be called immediately after each test.
     39 void ELFBinaryReaderTest::TearDown()
     40 {
     41 }
     42 
     43 //===----------------------------------------------------------------------===//
     44 // Testcases
     45 //===----------------------------------------------------------------------===//
     46 TEST_F( ELFBinaryReaderTest, is_myformat) {
     47   LinkerScript script;
     48   Module module("test", script);
     49   LinkerConfig config;
     50   IRBuilder builder(module, config);
     51   ELFBinaryReader *reader = new ELFBinaryReader(builder, config);
     52 
     53   Input input("test.bin");
     54 
     55   bool doContinue = false;
     56   config.options().setBinaryInput();
     57   ASSERT_TRUE(reader->isMyFormat(input, doContinue));
     58 
     59   config.options().setBinaryInput(false);
     60   ASSERT_FALSE(reader->isMyFormat(input, doContinue));
     61 
     62   delete reader;
     63 }
     64 
     65