How to use the check50.c.compile function in check50

To help you get started, we’ve selected a few check50 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cs50 / check50 / tests / c_tests.py View on Github external
def test_leak(self):
        with open("leak.c", "w") as f:
            src =   '#include \n'\
                    'void leak() {malloc(sizeof(int));}\n'\
                    'int main() {\n'\
                    '    leak();\n'\
                    '}'
            f.write(src)

        check50.c.compile("leak.c")
        with self.assertRaises(check50.Failure):
            with check50.internal.register:
                check50.c.valgrind("./leak").exit()
github cs50 / check50 / tests / c_tests.py View on Github external
def test_no_leak(self):
        with open("foo.c", "w") as f:
            src = 'int main() {}'
            f.write(src)

        check50.c.compile("foo.c")
        with check50.internal.register:
            check50.c.valgrind("./foo").exit()
github cs50 / check50 / tests / c_tests.py View on Github external
def test_compile_hello_world(self):
        with open("hello.c", "w") as f:
            src =   '#include \n'\
                    'int main() {\n'\
                    '    printf("hello, world!\\n");\n'\
                    '}'
            f.write(src)

        check50.c.compile("hello.c")

        self.assertTrue(os.path.isfile("hello"))
        check50.run("./hello").stdout("hello, world!", regex=False)
github cs50 / check50 / demo / hello / check50 / __init__.py View on Github external
def compiles():
    """hello.c compiles"""
    check50.c.compile("hello.c")