How to catch segmentation fault with Google Test?
问题 How do I test that a function won't produce a segmentation fault? Here what I know right now, I can do: EXPECT_DEATH(foo(nullParameter)) In side the function, a segmentation fault is produce which is the behavior that I want to make fail. The snippet above will make the test pass because that is what is expected, the death of the process. Now, how can I make it fail? 回答1: Here's a function that will segfault if passed a null pointer argument and otherwise not: int deref(int * pint) { return