From 4a5eb884a9a084e61287e3ab9b03b314b712173d Mon Sep 17 00:00:00 2001 From: msfur Date: Mon, 13 Jan 2025 11:53:58 +0100 Subject: [PATCH] Add a new test based on issue #440 --- tests/test_ads.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_ads.py b/tests/test_ads.py index 068db61d..ec2cd1c1 100644 --- a/tests/test_ads.py +++ b/tests/test_ads.py @@ -847,6 +847,23 @@ def test_bytes_from_dict(self) -> None: # fmt: on self.assertEqual(bytes_list, pyads.bytes_from_dict(values, structure_def)) + # test single nested structure (issue #440) + structure_def = ( + ('iVar9', pyads.PLCTYPE_USINT, 1), + ('structVar', substructure_def, 1), + ) + values = OrderedDict( + [ + ("iVar9", 29), + ("structVar", subvalues) + ] + ) + # fmt: off + bytes_list = [29] + subbytes_list + + # fmt: on + self.assertEqual(bytes_list, pyads.bytes_from_dict(values, structure_def)) + def test_dict_slice_generator(self): """test _dict_slice_generator function.""" test_dict = {