-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add node util tests. Version release
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "1.7.0-dev" | ||
__version__ = "1.7.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
from .unittest_utils import RDLSourceTestCase | ||
|
||
#=============================================================================== | ||
# Validate inferred field bit placement/packing | ||
#=============================================================================== | ||
class TestNodeUtils(RDLSourceTestCase): | ||
|
||
def test_index_tools(self): | ||
top = self.compile( | ||
["rdl_testcases/address_packing.rdl"], | ||
"hier" | ||
) | ||
|
||
with self.subTest("hier.x"): | ||
node = top.find_by_path("hier.x") | ||
self.assertEqual(node.get_path(), "hier.x") | ||
node.clear_lineage_index() | ||
self.assertEqual(node.get_path(), "hier.x") | ||
node.zero_lineage_index() | ||
self.assertEqual(node.get_path(), "hier.x") | ||
|
||
with self.subTest("hier.y.a"): | ||
node = top.find_by_path("hier.y[2].a") | ||
self.assertEqual(node.get_path(), "hier.y[2].a[][]") | ||
node.zero_lineage_index() | ||
self.assertEqual(node.get_path(), "hier.y[0].a[0][0]") | ||
node.clear_lineage_index() | ||
self.assertEqual(node.get_path(), "hier.y[].a[][]") | ||
|
||
def test_address_tools(self): | ||
top = self.compile( | ||
["rdl_testcases/address_packing.rdl"], | ||
"hier" | ||
) | ||
|
||
with self.subTest("hier.y[2].a"): | ||
node = top.find_by_path("hier.y[2].a") | ||
with self.assertRaises(ValueError): | ||
node.address_offset | ||
with self.assertRaises(ValueError): | ||
node.absolute_address | ||
self.assertEqual(node.raw_address_offset, 0) | ||
self.assertEqual(node.raw_absolute_address, 0x100) | ||
|
||
with self.subTest("hier.y.c[1][1]"): | ||
node = top.find_by_path("hier.y.c[1][1]") | ||
self.assertEqual(node.address_offset, 0x64 + 4*4+4) | ||
with self.assertRaises(ValueError): | ||
node.absolute_address | ||
self.assertEqual(node.raw_address_offset, 0x64) | ||
self.assertEqual(node.raw_absolute_address, 0x100 + 0x64) | ||
|
||
def test_repr(self): | ||
top = self.compile( | ||
["rdl_testcases/address_packing.rdl"], | ||
"hier" | ||
) | ||
|
||
node = top.find_by_path("hier.x.b.a") | ||
self.assertRegex(str(node), "<FieldNode hier\.x\.b\[\]\.a at 0x\w+>") |