ChaiScript / ChaiScript
1
// Tests to make sure that the order in which function dispatches occur is correct
2

3
#ifdef _MSC_VER
4
#pragma warning(push)
5
#pragma warning(disable : 4062 4242 4640 4702 6330 28251)
6
#endif
7

8
#ifdef __GNUC__
9
#pragma GCC diagnostic push
10
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
11
#pragma GCC diagnostic ignored "-Wparentheses"
12
#endif
13

14
#include <chaiscript/chaiscript_defines.hpp>
15
#include <chaiscript/dispatchkit/type_info.hpp>
16
#include <cstdlib>
17
#include <iostream>
18

19
#define CATCH_CONFIG_MAIN
20

21
#include "catch.hpp"
22

23 1
TEST_CASE("Type_Info objects generate expected results") {
24
  const auto test_type
25 1
      = [](const chaiscript::Type_Info &ti, bool t_is_const, bool t_is_pointer, bool t_is_reference, bool t_is_void, bool t_is_undef, bool t_is_arithmetic) {
26 1
          CHECK(ti.is_const() == t_is_const);
27 1
          CHECK(ti.is_pointer() == t_is_pointer);
28 1
          CHECK(ti.is_reference() == t_is_reference);
29 1
          CHECK(ti.is_void() == t_is_void);
30 1
          CHECK(ti.is_undef() == t_is_undef);
31 1
          CHECK(ti.is_arithmetic() == t_is_arithmetic);
32 1
        };
33

34 1
  SECTION("void") { test_type(chaiscript::user_type<void>(), false, false, false, true, false, false); }
35 1
  SECTION("const int") { test_type(chaiscript::user_type<const int>(), true, false, false, false, false, true); }
36 1
  SECTION("const int &") { test_type(chaiscript::user_type<const int &>(), true, false, true, false, false, true); }
37 1
  SECTION("int") { test_type(chaiscript::user_type<int>(), false, false, false, false, false, true); }
38 1
  SECTION("int *") { test_type(chaiscript::user_type<int *>(), false, true, false, false, false, false); }
39 1
  SECTION("const int *") { test_type(chaiscript::user_type<const int *>(), true, true, false, false, false, false); }
40 1
  SECTION("const bool &") { test_type(chaiscript::user_type<const bool &>(), true, false, true, false, false, false); }
41 1
  SECTION("default") { test_type(chaiscript::Type_Info(), false, false, false, false, true, false); }
42

43 1
  std::cout << "Size of Type_Info " << sizeof(chaiscript::Type_Info) << '\n';
44
}

Read our documentation on viewing source code .

Loading