generated from cpp-best-practices/gui_starter_template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_bypass_tests.cpp
35 lines (31 loc) · 1.11 KB
/
check_bypass_tests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// For more on how to use the excellent Catch test framework see
// https://github.com/catchorg/Catch2
#include "check_bypass.hpp"
#include <catch2/catch.hpp>
TEST_CASE("[check_bypass][1] CWE-190 (Unsigned): Integer Overflow or Wraparound", "[check_bypass]")
{
// Unsigned : Small enough
REQUIRE(bypassedCheckUnsigned(42, 42));
// Unsigned : Too big
REQUIRE(!bypassedCheckUnsigned(256, 256));
// Unsigned : Bypass check
//REQUIRE( bypassedCheckUnsigned(<FIRST>, <SECOND>) );
}
TEST_CASE("[check_bypass][2] CWE-190 (Signed): Integer Overflow or Wraparound", "[check_bypass]")
{
// Signed : Small enough
REQUIRE(bypassedCheckSigned(42, 42));
// Signed : Too big
REQUIRE(!bypassedCheckSigned(256, 256));
// Signed : Bypass check
//REQUIRE( bypassedCheckSigned(<FIRST>, <SECOND>) );
}
TEST_CASE("[check_bypass][3] CWE-197 (Truncation): Numeric Truncation Error", "[check_bypass]")
{
// Truncated : Small enough
REQUIRE(bypassedCheckTruncated(42, 42));
// Truncated : Too big
REQUIRE(!bypassedCheckTruncated(256, 256));
// Truncated : Bypass check
//REQUIRE( bypassedCheckTruncated(<FIRST>, <SECOND>) );
}