Last active
April 30, 2017 14:07
-
-
Save marijnvdwerf/3c2ea6d4ea726815866fd94d4dd0d109 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void doesntCrash_1() { | |
log_error("⇢ %s",__FUNCTION__); | |
auto fs = FileStream("/nonexistant.png", FILE_MODE_WRITE); | |
UNUSED(fs); | |
log_error("⇠ %s",__FUNCTION__); | |
} | |
void doesntCrash_2() { | |
log_error("⇢ %s",__FUNCTION__); | |
auto fs = FileStream("/nonexistant.png", FILE_MODE_WRITE); | |
UNUSED(fs); | |
log_error("⇠ %s",__FUNCTION__); | |
} | |
void doesntCrash_3() { | |
log_error("⇢ %s",__FUNCTION__); | |
auto fs = new FileStream("/nonexistant.png", FILE_MODE_WRITE); | |
UNUSED(fs); | |
delete fs; | |
throw IOException("Lets not do this"); | |
log_error("⇠ %s",__FUNCTION__); | |
} | |
void crashes() { | |
log_error("⇢ %s",__FUNCTION__); | |
auto fs = FileStream("/nonexistant.png", FILE_MODE_WRITE); | |
UNUSED(fs); | |
log_error(" - throw IOException"); | |
throw IOException("Lets not do this"); | |
log_error("⇠ %s",__FUNCTION__); | |
} | |
extern "C" { | |
int SDL_main(int argc, char *argv[]) { | |
doesntCrash_1(); | |
doesntCrash_2(); | |
try { | |
doesntCrash_3(); | |
} catch (Exception e) { | |
log_error("caught %s", e.GetMessage()); | |
} | |
try { | |
crashes(); | |
} catch (Exception e) { | |
log_error("caught %s", e.GetMessage()); | |
} | |
return 1; | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment