Skip to content

Commit

Permalink
Implementing unit tests for MemoryMap.py::caluclateObjectsInSections(…
Browse files Browse the repository at this point in the history
…) and bugfixes

Details:
    - Adding different test cases to test the MemoryMap.py::caluclateObjectsInSections() function
    - Bugfix in the MemoryMap.py::caluclateObjectsInSections() function
    - Defining an exception throwing empty __eq__ operator for the memoryEntry.py::MemEntry class
  • Loading branch information
KGergo88 committed Jul 4, 2019
1 parent 138675f commit b7bfe55
Show file tree
Hide file tree
Showing 4 changed files with 545 additions and 43 deletions.
3 changes: 3 additions & 0 deletions emma_libs/memoryEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def equalConfigID(self, other):
"""
return self.configID == other.configID

def __eq__(self, other):
raise NotImplementedError("Operator __eq__ not defined between " + type(self).__name__ + " objects!")

def __lt__(self, other):
"""
We only want the `<` operator to compare the address start element (dec); nothing else
Expand Down
2 changes: 1 addition & 1 deletion emma_libs/memoryMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def cutOffTheBeginningOfTheSection(sectionToCut, newAddressStart):
cutOffTheBeginningOfTheSection(sectionCopy, objectContainerElement.addressEnd + 1)

# Case 3: The object is overlapping the end of the section
elif sectionCopy.addressStart < objectContainerElement.addressStart <= sectionCopy.addressEnd < objectContainerElement.addressEnd:
elif sectionCopy.addressStart < objectContainerElement.addressStart <= sectionCopy.addressEnd <= objectContainerElement.addressEnd:
# Creating the sectionReserve
createASectionReserve(sectionCopy, objectContainerElement.addressStart - 1)
# This object is overlapping the end of the section. This means that all the following objects will be
Expand Down
1 change: 0 additions & 1 deletion tests/unit_tests/test_memoryEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def test_ConstructorAddressLengthAndAddressEnd(self):
self.assertEqual(entryWithLengthAndAddressEnd.addressLength, self.addressLength)
self.assertEqual(entryWithLengthAndAddressEnd.addressEnd, (self.addressStart + self.addressLength - 1))


def test_ConstructorDmaEntry(self):
# Testing the creation of a DMA entry
entryWithDma = emma_libs.memoryEntry.MemEntry(tag=self.tag, vasName=None, vasSectionName=self.vasSectionName,
Expand Down
Loading

0 comments on commit b7bfe55

Please sign in to comment.