Merge branch '0.8' to sync with changes made after 0.8.1 release.
[luabind.git] / test / test_builtin_converters.cpp
blob321ddfdb689f8226291dd55ca1272fca760a51a5
1 // Copyright Daniel Wallin 2009. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include "test.hpp"
7 #include <luabind/luabind.hpp>
9 #define LUABIND_TEST_BUILTIN(type, value) \
10 default_converter<type>().to(L, value); \
11 default_converter<type> BOOST_PP_CAT(cv, __LINE__); \
12 TEST_CHECK(BOOST_PP_CAT(cv, __LINE__).compute_score(L, -1) >= 0); \
13 TEST_CHECK(BOOST_PP_CAT(cv, __LINE__).from(L, -1) == value); \
14 lua_pop(L, 1)
16 void test_main(lua_State* L)
18 using namespace luabind;
20 LUABIND_TEST_BUILTIN(int, 1);
21 LUABIND_TEST_BUILTIN(int, -1);
22 LUABIND_TEST_BUILTIN(unsigned int, 1);
23 LUABIND_TEST_BUILTIN(unsigned int, 2);
25 LUABIND_TEST_BUILTIN(short, 1);
26 LUABIND_TEST_BUILTIN(short, -1);
27 LUABIND_TEST_BUILTIN(unsigned short, 1);
28 LUABIND_TEST_BUILTIN(unsigned short, 2);
30 LUABIND_TEST_BUILTIN(long, 1);
31 LUABIND_TEST_BUILTIN(long, -1);
32 LUABIND_TEST_BUILTIN(unsigned long, 1);
33 LUABIND_TEST_BUILTIN(unsigned long, 2);
35 LUABIND_TEST_BUILTIN(char, 1);
36 LUABIND_TEST_BUILTIN(char, 2);
37 LUABIND_TEST_BUILTIN(unsigned char, 1);
38 LUABIND_TEST_BUILTIN(unsigned char, 2);
39 LUABIND_TEST_BUILTIN(signed char, -1);
40 LUABIND_TEST_BUILTIN(signed char, 1);
42 LUABIND_TEST_BUILTIN(float, 1.5);
43 LUABIND_TEST_BUILTIN(float, -1.5);
45 LUABIND_TEST_BUILTIN(double, 1.5);
46 LUABIND_TEST_BUILTIN(double, -1.5);
48 LUABIND_TEST_BUILTIN(bool, true);
49 LUABIND_TEST_BUILTIN(bool, false);