Coverage for hdl_registers/test/unit/test_register_cpp_generator.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-01-29 22:03 +0000

1# -------------------------------------------------------------------------------------------------- 

2# Copyright (c) Lukas Vik. All rights reserved. 

3# 

4# This file is part of the hdl_registers project, a HDL register generator fast enough to be run 

5# in real time. 

6# https://hdl-registers.com 

7# https://gitlab.com/hdl_registers/hdl_registers 

8# -------------------------------------------------------------------------------------------------- 

9 

10# Standard libraries 

11import unittest 

12 

13# Third party libraries 

14import pytest 

15from tsfpga.system_utils import read_file 

16 

17# First party libraries 

18from hdl_registers import HDL_REGISTERS_TEST 

19from hdl_registers.parser import from_toml 

20 

21 

22@pytest.mark.usefixtures("fixture_tmp_path") 

23class TestRegisterCppGenerator(unittest.TestCase): 

24 """ 

25 Note that there are further tests in test_register_compilation.py. 

26 """ 

27 

28 tmp_path = None 

29 

30 def setUp(self): 

31 toml_file = HDL_REGISTERS_TEST / "regs_test.toml" 

32 self.registers = from_toml("test", toml_file) 

33 

34 self.registers.create_cpp_interface(self.tmp_path) 

35 self.cpp = read_file(self.tmp_path / "i_test.h") 

36 

37 def test_read_only_register_has_no_setters(self): 

38 assert "get_status" in self.cpp 

39 assert "set_status" not in self.cpp 

40 

41 def test_write_only_register_has_no_setters(self): 

42 assert "set_command" in self.cpp 

43 assert "get_command" not in self.cpp