2#include <cppunit/extensions/HelperMacros.h>
3#include <cppunit/TestFixture.h>
5#include "../../src/linker/section.h"
15 CPPUNIT_TEST(testSimpleFlags);
16 CPPUNIT_TEST(testZeroFilledFlag);
17 CPPUNIT_TEST(testFixedFlag);
18 CPPUNIT_TEST_SUITE_END();
21 void testSimpleFlags();
22 void testZeroFilledFlag();
25 void setUp()
override;
26 void tearDown()
override;
29void TestSection::testSimpleFlags()
31 CPPUNIT_ASSERT_MESSAGE(
"Default setting should be Readable", section->GetFlags() ==
Section::Readable);
33 section->SetWritable(
true);
34 CPPUNIT_ASSERT(section->IsWritable());
35 section->SetExecutable(
true);
36 CPPUNIT_ASSERT(section->IsExecutable());
37 section->SetMergeable(
true);
38 CPPUNIT_ASSERT(section->IsMergeable());
40 section->SetReadable(
false);
41 CPPUNIT_ASSERT(!section->IsReadable());
42 section->SetExecutable(
false);
43 CPPUNIT_ASSERT(!section->IsExecutable());
44 section->SetWritable(
false);
45 CPPUNIT_ASSERT(!section->IsWritable());
46 section->SetMergeable(
false);
47 CPPUNIT_ASSERT(!section->IsMergeable());
50void TestSection::testZeroFilledFlag()
52 section->SetZeroFilled(
true);
54 CPPUNIT_ASSERT_EQUAL(offset_t(123), section->Size());
55 section->SetZeroFilled(
false);
56 CPPUNIT_ASSERT_EQUAL(offset_t(123), section->Size());
59void TestSection::testFixedFlag()
61 CPPUNIT_ASSERT(!section->IsFixed());
62 section->SetAlign(16);
63 CPPUNIT_ASSERT_EQUAL(offset_t(16), section->GetAlign());
64 CPPUNIT_ASSERT_EQUAL(offset_t(0), section->GetStartAddress());
66 CPPUNIT_ASSERT(section->IsFixed());
67 CPPUNIT_ASSERT_EQUAL(offset_t(0x1240), section->GetStartAddress());
70void TestSection::setUp()
75void TestSection::tearDown()
A section of data as read from an object file.
Definition section.h:24
offset_t SetAddress(offset_t new_address)
For non-fixed segments, sets the starting address and makes the fixed.
Definition section.cc:144
offset_t Expand(offset_t new_size)
Increases the size of the section by the specified amount.
Definition section.cc:176
@ Readable
The data in the section can be read at runtime.
Definition section.h:43