def test_ifndef_unfulfilled_define_ignored(): f_obj = FakeFile("header.h", ["#define FOO\n", "#ifndef FOO\n", "#define BAR 1\n", "#endif\n", "BAR\n"]) expected = "BAR\n" run_case(f_obj, expected)
def test_unsupported_pragma(): f_obj = FakeFile("header.h", ["#pragma bogus\n"]) with pytest.raises(ParseError) as excinfo: "".join(preprocess(f_obj)) assert "Unsupported pragma" in str(excinfo.value)
def test_unexpected_macro_gives_parse_error(): f_obj = FakeFile("header.h", ["#something_unsupported foo bar\n"]) with pytest.raises(ParseError): "".join(preprocess(f_obj))
def test_define_undefine(): f_obj = FakeFile("header.h", ["#define FOO 1\n", "#undef FOO\n", "FOO\n"]) expected = "FOO\n" run_case(f_obj, expected)
def test_define_parens(): f_obj = FakeFile("header.h", ["#define FOO (x)\n", "FOO\n"]) expected = "(x)\n" run_case(f_obj, expected)
def test_blank_define(): f_obj = FakeFile("header.h", ["#define FOO\n", "FOO\n"]) expected = "\n" run_case(f_obj, expected)
def test_define_indirect__reference(): f_obj = FakeFile("header.h", ["#define x (4 + y)\n", "#define y (2 * x)\n", "x\n", "y\n"]) expected = "(4 + (2 * x))\n(2 * (4 + y))\n" run_case(f_obj, expected)
def test_expand_size_t(): f_obj = FakeFile("header.h", ["__SIZE_TYPE__\n"]) expected = "size_t\n" run_case(f_obj, expected)