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

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

20

21

22

23
#define CATCH_CONFIG_MAIN
24

25
#include "catch.hpp"
26

27

28 1
TEST_CASE("Type_Info objects generate expected results")
29
{
30
  const auto test_type = [](const chaiscript::Type_Info &ti, bool t_is_const, bool t_is_pointer, bool t_is_reference, bool t_is_void,
31 1
    bool t_is_undef, bool t_is_arithmetic)
32
  {
33 1
    CHECK(ti.is_const() == t_is_const);
34 1
    CHECK(ti.is_pointer() == t_is_pointer);
35 1
    CHECK(ti.is_reference() == t_is_reference);
36 1
    CHECK(ti.is_void() == t_is_void);
37 1
    CHECK(ti.is_undef() == t_is_undef);
38 1
    CHECK(ti.is_arithmetic() == t_is_arithmetic);
39 1
  };
40

41 1
  SECTION("void") {  test_type(chaiscript::user_type<void>(), false, false, false, true, false, false); }
42 1
  SECTION("const int") { test_type(chaiscript::user_type<const int>(), true, false, false, false, false, true); }
43 1
  SECTION("const int &") { test_type(chaiscript::user_type<const int &>(), true, false, true, false, false, true); }
44 1
  SECTION("int") { test_type(chaiscript::user_type<int>(), false, false, false, false, false, true); }
45 1
  SECTION("int *") { test_type(chaiscript::user_type<int *>(), false, true, false, false, false, false); }
46 1
  SECTION("const int *") { test_type(chaiscript::user_type<const int *>(), true, true, false, false, false, false); }
47 1
  SECTION("const bool &") { test_type(chaiscript::user_type<const bool &>(), true, false, true, false, false, false); }
48 1
  SECTION("default") { test_type(chaiscript::Type_Info(), false, false, false, false, true, false); }
49

50 1
  std::cout << "Size of Type_Info " << sizeof(chaiscript::Type_Info) << '\n';
51
}
52

53

54

Read our documentation on viewing source code .

Loading