public void ResetTest() { var objectFile = new ObjectFileMock(); Context context = new Context(objectFile); Section section = new Section("Test"); var symbol = new Symbol(SymbolType.Public, "test"); var relocation = new Relocation(symbol, section, 0, 0, RelocationType.Default32); context.SymbolTable.Add(symbol); context.RelocationTable.Add(relocation); context.Section = section; context.Address = 123456789; Assert.AreEqual(symbol, context.SymbolTable[0]); Assert.AreEqual(relocation, context.RelocationTable[0]); Assert.AreEqual(section, context.Section); Assert.AreEqual((Int128)123456789, context.Address); context.Reset(); // These have not changed Assert.AreEqual(symbol, context.SymbolTable[0]); Assert.AreEqual(relocation, context.RelocationTable[0]); // These are reset Assert.AreEqual(null, context.Section); Assert.AreEqual((Int128)0, context.Address); }
public void AddressTest() { var objectFile = new ObjectFileMock(); Context context = new Context(objectFile); context.Address = 123456789; Assert.AreEqual((Int128)123456789, context.Address); }
public void ConstructorTest() { var objectFile = new ObjectFileMock(); Context context = new Context(objectFile); Assert.AreEqual(objectFile, context.Representation); Assert.IsNotNull(context.RelocationTable); Assert.IsNotNull(context.SymbolTable); }
public void SectionTest() { var objectFile = new ObjectFileMock(); Context context = new Context(objectFile); Section section = new Section("Test"); context.Section = section; Assert.AreEqual(section, context.Section); }
public void AddNewSectionTest() { ObjectFile objectfile = new ObjectFileMock(); objectfile.Sections.AddNew(SectionType.Program, ".text"); Assert.IsTrue(objectfile.Sections[0].Allocate); Assert.IsTrue(objectfile.Sections[0].Executable); Assert.IsFalse(objectfile.Sections[0].Writable); Assert.IsFalse(objectfile.Sections[0].NoBits); objectfile.Sections.AddNew(SectionType.Data, ".data"); Assert.IsTrue(objectfile.Sections[1].Allocate); Assert.IsFalse(objectfile.Sections[1].Executable); Assert.IsTrue(objectfile.Sections[1].Writable); Assert.IsFalse(objectfile.Sections[1].NoBits); objectfile.Sections.AddNew(SectionType.Bss, ".bss"); Assert.IsTrue(objectfile.Sections[2].Allocate); Assert.IsFalse(objectfile.Sections[2].Executable); Assert.IsTrue(objectfile.Sections[2].Writable); Assert.IsTrue(objectfile.Sections[2].NoBits); }