[libc++] More consistency with declaring int main(int, char**)

This commit is contained in:
Louis Dionne 2020-10-09 10:08:42 -04:00
parent fa200dc359
commit 86d61365d8
1 changed files with 8 additions and 6 deletions

View File

@ -107,18 +107,19 @@ class TestSourceBuilds(SetupConfigs):
Tests for libcxx.test.dsl.sourceBuilds
"""
def test_valid_program_builds(self):
source = """int main(int, char**) { }"""
source = """int main(int, char**) { return 0; }"""
self.assertTrue(dsl.sourceBuilds(self.config, source))
def test_compilation_error_fails(self):
source = """in main(int, char**) { }"""
source = """int main(int, char**) { this does not compile }"""
self.assertFalse(dsl.sourceBuilds(self.config, source))
def test_link_error_fails(self):
source = """extern void this_isnt_defined_anywhere();
int main(int, char**) { this_isnt_defined_anywhere(); }"""
int main(int, char**) { this_isnt_defined_anywhere(); return 0; }"""
self.assertFalse(dsl.sourceBuilds(self.config, source))
class TestProgramOutput(SetupConfigs):
"""
Tests for libcxx.test.dsl.programOutput
@ -126,20 +127,20 @@ class TestProgramOutput(SetupConfigs):
def test_valid_program_returns_output(self):
source = """
#include <cstdio>
int main(int, char**) { std::printf("FOOBAR"); }
int main(int, char**) { std::printf("FOOBAR"); return 0; }
"""
self.assertEqual(dsl.programOutput(self.config, source), "FOOBAR")
def test_valid_program_returns_output_newline_handling(self):
source = """
#include <cstdio>
int main(int, char**) { std::printf("FOOBAR\\n"); }
int main(int, char**) { std::printf("FOOBAR\\n"); return 0; }
"""
self.assertEqual(dsl.programOutput(self.config, source), "FOOBAR\n")
def test_valid_program_returns_no_output(self):
source = """
int main(int, char**) { }
int main(int, char**) { return 0; }
"""
self.assertEqual(dsl.programOutput(self.config, source), "")
@ -165,6 +166,7 @@ class TestProgramOutput(SetupConfigs):
assert(argc == 3);
assert(argv[1] == std::string("first-argument"));
assert(argv[2] == std::string("second-argument"));
return 0;
}
"""
args = ["first-argument", "second-argument"]