Empirical
test_assert.h
Go to the documentation of this file.
1 // This file is part of Empirical, https://github.com/devosoft/Empirical
2 // Copyright (C) Michigan State University, 2016-2017.
3 // Released under the MIT Software license; see doc/LICENSE
4 //
5 // Tests for files in the base/ folder.
6 
7 #ifndef EMP_TRACK_MEM
8 #define EMP_TRACK_MEM
9 #endif
10 
11 #define CATCH_CONFIG_MAIN
12 #undef NDEBUG
13 #define TDEBUG 1
14 
15 #include "../third-party/Catch/single_include/catch.hpp"
16 
17 TEST_CASE("Test assert", "[tools]")
18 {
19  // Asserts are tricky to test. Here are a bunch that should PASS.
20  emp_assert(true);
21  REQUIRE(emp::assert_last_fail == 0);
22 
23  emp_assert(100);
24  REQUIRE(emp::assert_last_fail == 0);
25 
26  emp_assert(23 < 24);
27  REQUIRE(emp::assert_last_fail == 0);
28 
29  emp_assert((14 < 13)?0:1);
30  REQUIRE(emp::assert_last_fail == 0);
31 
32 
33  // Now here are some that should FAIL
34 /* emp_assert(false);
35  EMP_TEST_VALUE(emp::assert_last_fail, "1");
36  EMP_TEST_VALUE(emp::assert_fail_info.filename, "assert.cc");
37  EMP_TEST_VALUE(emp::assert_fail_info.line_num, "31");
38  EMP_TEST_VALUE(emp::assert_fail_info.error, "false");
39 */
40  // if (emp::assert_fail_info.filename != "assert.cc") std::cerr << "Failed case 6!" << std::endl;
41  // if (emp::assert_fail_info.line_num != __LINE__ - 3) std::cerr << "Failed case 7!" << std::endl;
42  // if (emp::assert_fail_info.error != "false") std::cerr << "Failed case 8!" << std::endl;
43 }
TEST_CASE("Test assert","[tools]")
Definition: test_assert.h:17
#define emp_assert(...)
Definition: assert.h:199