summaryrefslogtreecommitdiff
path: root/src/tools/docwriter/tests/test_parse.py
blob: 7df95c081a40b389d9d33d3d54713e3f0085c293 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
#  test_parse.py
#
#    Tests for docwriter parsing (sources.py and content.py).
#
#  Copyright 2018 by
#  Nikhil Ramakrishnan.
#
#  This file is part of the FreeType project, and may only be used,
#  modified, and distributed under the terms of the FreeType project
#  license, LICENSE.TXT.  By continuing to use, modify, or distribute
#  this file you indicate that you have read the license and
#  understand and accept it fully.

"""Docwriter parse tests.

The tests in this module use the `SourceProcessor` and
`ContentProcessor` classes to test file and content parsing.
"""

import content
import sources
import utils

# create context and processor
source_processor  = sources.SourceProcessor()
content_processor = content.ContentProcessor()

def test_parse_file():
    # retrieve the list of files to process
    file_list = utils.make_file_list( ['./tests/assets/*.c'] )
    for filename in file_list:
        source_processor.parse_file( filename )
    # get blocks
    blocks = source_processor.blocks
    count  = len( blocks )

    # there must be 12 blocks in file
    assert count == 12

def test_parse_source():
    # retrieve the list of files to process
    file_list = utils.make_file_list( ['./tests/assets/*.c'] )
    for filename in file_list:
        source_processor.parse_file( filename )
        content_processor.parse_sources( source_processor )
    # process sections
    content_processor.finish()
    # get headers
    headers = content_processor.headers
    # expected values
    expected_key = 'freetype/ftbbox.h'
    expected_val = 'FT_BBOX_H'

    assert headers[expected_key] == expected_val

# eof