c++ - In gtest, can you try/catch a function that calls "exit(1)"? -
there's function calls exit(1) specific cases, , i'm trying run unit tests gtest on function.
i thought i'd able use try/catch case function calls exit(1), doesn't catch me.
is normal behavior? if so, how else should detect exit(1) called?
unlike in, say, python, exit() function of c , c++ doesn't work throwing exception. once has done c runtime cleanup (e.g. calling registered atexit() handlers), directly calls kernel terminate process, , control never returns program.
the news that
google test support testing program exit:
assert_exit(statement, predicate, regex);,expect_exit(statement, predicate, regex);
statementexits given error , exit code matchespredicate
i haven't checked, guess implemented fork()ing test, , waiting child terminate.
Comments
Post a Comment