Coverage for hdl_registers/generator/vhdl/test/test_record_package.py: 100%
16 statements
« prev ^ index » next coverage.py v7.6.8, created at 2024-12-01 20:50 +0000
« prev ^ index » next coverage.py v7.6.8, created at 2024-12-01 20:50 +0000
1# --------------------------------------------------------------------------------------------------
2# Copyright (c) Lukas Vik. All rights reserved.
3#
4# This file is part of the hdl-registers project, an HDL register generator fast enough to run
5# in real time.
6# https://hdl-registers.com
7# https://github.com/hdl-registers/hdl-registers
8# --------------------------------------------------------------------------------------------------
10"""
11Some limited unit tests.
12Note that the generated VHDL code is also simulated in a functional test.
13"""
15# First party libraries
16from hdl_registers.generator.vhdl.record_package import VhdlRecordPackageGenerator
17from hdl_registers.register_list import RegisterList
18from hdl_registers.register_modes import REGISTER_MODES
21def test_package_is_not_generated_without_registers(tmp_path):
22 register_list = RegisterList(name="test", source_definition_file=None)
24 assert not (VhdlRecordPackageGenerator(register_list, tmp_path).create()).exists()
26 register_list.add_constant(name="apa", value=True, description="")
27 assert not (VhdlRecordPackageGenerator(register_list, tmp_path).create()).exists()
29 register_list.append_register(name="hest", mode=REGISTER_MODES["r_w"], description="")
30 assert (VhdlRecordPackageGenerator(register_list, tmp_path).create()).exists()
33def test_re_generating_package_without_registers_should_delete_old_file(tmp_path):
34 register_list = RegisterList(name="test", source_definition_file=None)
35 register_list.append_register(name="apa", mode=REGISTER_MODES["r_w"], description="")
37 assert (VhdlRecordPackageGenerator(register_list, tmp_path).create()).exists()
39 register_list.register_objects = []
40 assert not (VhdlRecordPackageGenerator(register_list, tmp_path).create()).exists()