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

19 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2022-09-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/tsfpga/hdl_registers 

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

9 

10import unittest 

11 

12import pytest 

13 

14from tsfpga.system_utils import read_file 

15 

16from hdl_registers import HDL_REGISTERS_TEST 

17from hdl_registers.parser import from_toml 

18 

19 

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

21class TestRegisterCppGenerator(unittest.TestCase): 

22 """ 

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

24 """ 

25 

26 tmp_path = None 

27 

28 def setUp(self): 

29 toml_file = HDL_REGISTERS_TEST / "regs_test.toml" 

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

31 

32 self.registers.create_cpp_interface(self.tmp_path) 

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

34 

35 def test_read_only_register_has_no_setters(self): 

36 assert "get_status" in self.cpp 

37 assert "set_status" not in self.cpp 

38 

39 def test_write_only_register_has_no_setters(self): 

40 assert "set_command" in self.cpp 

41 assert "get_command" not in self.cpp