1"""
2Copyright (c) 2022 Teslabs Engineering S.L.
3SPDX-License-Identifier: Apache 2.0
4"""
5
6from gd32headers import main
7
8
9def test_main(data, hal_path, tmp_path):
10    """Test that common headers are generated correctly."""
11
12    main(hal_path, tmp_path)
13
14    # check adc file
15    ref_adc_file = data / "gd32_adc.h"
16    gen_adc_file = tmp_path / "gd32_adc.h"
17
18    assert gen_adc_file.exists()
19
20    with open(ref_adc_file) as ref, open(gen_adc_file) as gen:
21        assert ref.read() == gen.read()
22
23    # check libopt file is not created (not an API)
24    gen_libopt_file = tmp_path / "gd32_libopt.h"
25
26    assert not gen_libopt_file.exists()
27