Пример #1
0
    def test_inside_comment(self):
        # Should not treat the second hash as it is inside a comment
        directive = PreprocessorDirective(['#endif // #define A'], 1)
        self.assertFalse(directive.uses_macro_tricks())

        directive = PreprocessorDirective(['#endif /* #define B */'], 2)
        self.assertFalse(directive.uses_macro_tricks())
Пример #2
0
    def test_variadic(self):
        directive = PreprocessorDirective(['#define PP(x,...) printf(x)'], 1)
        self.assertTrue(directive.uses_macro_tricks())

        # Mangle ellipsis ... so that it will not trigger the match
        directive = PreprocessorDirective(
            "#define eprintf(. . .) fprintf (stderr, __VA_ARGS__)", 1)
        self.assertTrue(directive.uses_macro_tricks())
Пример #3
0
 def test_stringify(self):
     directive = PreprocessorDirective(['#define A(x,y) A #x'], 1)
     self.assertTrue(directive.uses_macro_tricks())
Пример #4
0
 def test_concat(self):
     directive = PreprocessorDirective(['#define A(x,y) A##B'], 1)
     self.assertTrue(directive.uses_macro_tricks())
Пример #5
0
 def test_no_match(self):
     directive = PreprocessorDirective(["#ifdef __GNUC__"], 1)
     self.assertFalse(directive.uses_macro_tricks())
Пример #6
0
    def test_line_and_file(self):
        directive = PreprocessorDirective(['#define A "file" __FILE__'], 1)
        self.assertTrue(directive.uses_macro_tricks())

        directive = PreprocessorDirective(['#define A "line" __LINE__'], 2)
        self.assertTrue(directive.uses_macro_tricks())