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