forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include ../Makefile.tests_common | ||
|
||
# If you want to add some extra flags when compile c++ files, add these flags | ||
# to CXXEXFLAGS variable | ||
CXXEXFLAGS += -std=c++11 | ||
FEATURES_REQUIRED += cpp | ||
|
||
include $(RIOTBASE)/Makefile.include | ||
deps: $(BUILDDEPS) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2022 Jens Wetterich <[email protected]> | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup tests | ||
* @{ | ||
* @file | ||
* @brief Unit test to show the wrong behavior of c++ exceptions | ||
* @author Jens Wetterich <[email protected]> | ||
*/ | ||
|
||
#include <cstdio> | ||
#include <stdexcept> | ||
#include "test_utils/expect.h" | ||
|
||
int main() { | ||
puts("\n************ C++ exception test ***********"); | ||
|
||
bool enabled = false; | ||
|
||
if(__EXCEPTIONS) { | ||
puts("Exceptions enabled"); | ||
enabled = true; | ||
} else { | ||
puts("Exceptions disabled"); | ||
} | ||
|
||
expect(enabled); | ||
|
||
bool catched = false; | ||
|
||
try { | ||
throw std::runtime_error("Exception"); | ||
} catch(std::exception& e) { | ||
catched = true; | ||
printf("%s catched\n", e.what()); | ||
} | ||
|
||
expect(catched); | ||
|
||
puts("******************************************"); | ||
|
||
return 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (C) 2022 Jens Wetterich <[email protected]> | ||
# | ||
# This file is subject to the terms and conditions of the GNU Lesser | ||
# General Public License v2.1. See the file LICENSE in the top level | ||
# directory for more details. | ||
|
||
import sys | ||
from testrunner import run | ||
|
||
|
||
def testfunc(child): | ||
child.expect_exact("************ C++ exception test ***********") | ||
child.expect_exact("Exceptions enabled") | ||
child.expect_exact("Exception catched") | ||
child.expect_exact("******************************************") | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(run(testfunc)) |