FragmentTest.cpp revision 551ae4ebd3e9d137ea668fb83ae4a55b8cfba451
1//===- FragmentTest.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 "FragmentTest.h" 10 11#include <mcld/Fragment/Fragment.h> 12#include <mcld/LD/SectionData.h> 13#include <mcld/LD/LDSection.h> 14 15using namespace mcld; 16using namespace mcldtest; 17 18 19// Constructor can do set-up work for all test here. 20FragmentTest::FragmentTest() 21{ 22} 23 24// Destructor can do clean-up work that doesn't throw exceptions here. 25FragmentTest::~FragmentTest() 26{ 27} 28 29// SetUp() will be called immediately before each test. 30void FragmentTest::SetUp() 31{ 32} 33 34// TearDown() will be called immediately after each test. 35void FragmentTest::TearDown() 36{ 37} 38 39//===----------------------------------------------------------------------===// 40// Testcases 41 42TEST_F( FragmentTest, Fragment_constructor ) { 43 LDSection* test = LDSection::Create("test", LDFileFormat::Null, 0, 0); 44 SectionData* s = SectionData::Create(*test); 45 new Fragment(Fragment::Alignment, s); 46 EXPECT_TRUE(1 == s->size()); 47 new Fragment(Fragment::Alignment, s); 48 new Fragment(Fragment::Region, s); 49 new Fragment(Fragment::Fillment, s); 50 new Fragment(Fragment::Target, s); 51 EXPECT_TRUE(5 == s->size()); 52 53 LDSection::Destroy(test); 54// SectionData::Destroy(s); 55} 56 57TEST_F( FragmentTest, Fragment_trivial_function ) { 58 LDSection* test = LDSection::Create("test", LDFileFormat::Null, 0, 0); 59 SectionData* s = SectionData::Create(*test); 60 Fragment* f = new Fragment(Fragment::Alignment, s); 61 62 EXPECT_TRUE(Fragment::Alignment == f->getKind()); 63 64 f->setOffset(5566); 65 EXPECT_TRUE(5566 == f->getOffset()); 66 67 //always return true 68 EXPECT_TRUE(f->classof(new Fragment(Fragment::Region, s)) ); 69 70 LDSection::Destroy(test); 71// SectionData::Destroy(s); 72} 73 74 75