Ejemplo n.º 1
0
def parse_error():
    """Test that two structs with the same name raises an error."""
    code = 'struct a {int c;}; \nstruct b { int d; \nstruct a {int d;}; };'
    ast = cparser.parse(code, 'test')
    with contexts.raises(cparser.ParseError) as error:
        cparser.find_structs(ast)
    assert str(error).startswith('Two structs with same name a')
Ejemplo n.º 2
0
def cli_no_file(cli):
    """Test that providing no header or config prints usage message."""
    with contexts.capture_output() as (out, err):
        with contexts.raises(SystemExit) as error:
            headers, configs = csjark.parse_args(['-v', '-d'])
    assert str(error) == '2'
    assert out[0].startswith('usage:')
Ejemplo n.º 3
0
def cli_no_file(cli):
    """Test that providing no header or config prints usage message."""
    with contexts.capture_output() as (out, err):
        with contexts.raises(SystemExit) as error:
            headers, configs = csjark.parse_args(['-v', '-d'])
    assert str(error) == '2'
    assert out[0].startswith('usage:')
Ejemplo n.º 4
0
def parse_error():
    """Test that two structs with the same name raises an error."""
    code = 'struct a {int c;}; \nstruct b { int d; \nstruct a {int d;}; };'
    ast = cparser.parse(code, 'test')
    with contexts.raises(cparser.ParseError) as error:
        cparser.find_structs(ast)
    assert str(error).startswith('Two structs with same name a')
Ejemplo n.º 5
0
def cli_file_dont_existing(cli):
    """Test if a file is missing"""
    config = os.path.join(os.path.dirname(__file__), 'sprint2.yml')
    with contexts.capture_output() as (out, err):
        with contexts.raises(SystemExit) as error:
            headers, configs = csjark.parse_args(['404.h', config])
    assert str(error) == '2'
    assert out[0].startswith('Unknown file(s): 404.h')
Ejemplo n.º 6
0
def cli_file_dont_existing(cli):
    """Test if a file is missing"""
    config = os.path.join(os.path.dirname(__file__), 'sprint2.yml')
    with contexts.capture_output() as (out, err):
        with contexts.raises(SystemExit) as error:
            headers, configs = csjark.parse_args(['404.h', config])
    assert str(error) == '2'
    assert out[0].startswith('Unknown file(s): 404.h')
Ejemplo n.º 7
0
def req_1f():
    """Test requirement FR1-F: Detect same name structs."""
    cparser.StructVisitor.all_protocols = {}
    code = 'struct a {int c;};\nstruct b { int d;\nstruct a {int d;}; };'
    ast = cparser.parse(code, 'test')
    with contexts.raises(cparser.ParseError) as error:
        cparser.find_structs(ast)
    assert str(error).startswith('Two structs with same name a')
    cparser.StructVisitor.all_protocols = {}
Ejemplo n.º 8
0
def req_1f():
    """Test requirement FR1-F: Detect same name structs."""
    cparser.StructVisitor.all_protocols = {}
    code = 'struct a {int c;};\nstruct b { int d;\nstruct a {int d;}; };'
    ast = cparser.parse(code, 'test')
    with contexts.raises(cparser.ParseError) as error:
        cparser.find_structs(ast)
    assert str(error).startswith('Two structs with same name a')
    cparser.StructVisitor.all_protocols = {}