Skip to content

Commit 2b4fb31

Browse files
committed
Integer coverage
1 parent eb024e0 commit 2b4fb31

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

tests/std/test.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ tests\GH_005472_do_not_overlap
272272
tests\GH_005546_containers_size_type_cast
273273
tests\GH_005553_regex_character_translation
274274
tests\GH_005768_pow_accuracy
275+
tests\GH_005816_numeric_limits_traps
275276
tests\LWG2381_num_get_floating_point
276277
tests\LWG2510_tag_classes
277278
tests\LWG2597_complex_branch_cut
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
RUNALL_INCLUDE ..\usual_matrix.lst
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
#include <limits>
5+
6+
#include <test_death.hpp>
7+
8+
#ifdef __clang__
9+
#pragma clang diagnostic ignored "-Wc++17-extensions" // constexpr if is a C++17 extension
10+
#else
11+
#pragma warning(disable : 4984) // warning C4984: 'if constexpr' is a C++17 language extension
12+
#endif // __clang__
13+
14+
void trap_operation() {
15+
volatile int op1{1};
16+
volatile int op2{0};
17+
volatile int res = op1 / op2;
18+
(void) res;
19+
}
20+
21+
int main(int argc, char* argv[]) {
22+
if constexpr (std::numeric_limits<int>::traps) {
23+
std_testing::death_test_executive exec;
24+
const std_testing::death_function_t one_trap[] = {trap_operation};
25+
exec.add_death_tests(one_trap);
26+
return exec.run(argc, argv);
27+
} else {
28+
trap_operation();
29+
}
30+
}

0 commit comments

Comments
 (0)