Add support for string::substr #75

Also add forgotten missing test for number suffixes
This commit is contained in:
Jason Turner 2012-11-07 15:48:25 -07:00
parent 964342bff3
commit 923369a4f4
3 changed files with 17 additions and 0 deletions

View File

@ -625,6 +625,9 @@ namespace chaiscript
typedef typename String::size_type (String::*find_func_ptr)(const String &, typename String::size_type) const;
typedef boost::function<int (const String *, const String &, int)> find_func;
typedef String (String::*substr_ptr)(typename String::size_type, typename String::size_type) const;
typedef boost::function<String (const String *, int, int)> substr_func;
m->add(fun(find_func(detail::return_int(static_cast<find_func_ptr>(&String::find)))), "find");
m->add(fun(find_func(detail::return_int(static_cast<find_func_ptr>(&String::rfind)))), "rfind");
m->add(fun(find_func(detail::return_int(static_cast<find_func_ptr>(&String::find_first_of)))), "find_first_of");
@ -632,6 +635,8 @@ namespace chaiscript
m->add(fun(find_func(detail::return_int(static_cast<find_func_ptr>(&String::find_first_not_of)))), "find_first_not_of");
m->add(fun(find_func(detail::return_int(static_cast<find_func_ptr>(&String::find_last_not_of)))), "find_last_not_of");
m->add(fun(substr_func(static_cast<substr_ptr>(&String::substr))), "substr");
m->add(fun(&String::c_str), "c_str");
m->add(fun(&String::data), "data");

View File

@ -0,0 +1,11 @@
assert_equal(true, int_type.bare_equal(1.get_type_info()))
assert_equal(true, unsigned_int_type.bare_equal(1u.get_type_info()))
assert_equal(true, unsigned_long_type.bare_equal(1lu.get_type_info()))
assert_equal(true, long_type.bare_equal(1l.get_type_info()))
assert_equal(true, int64_t_type.bare_equal(1ll.get_type_info()))
assert_equal(true, uint64_t_type.bare_equal(1ull.get_type_info()))
assert_equal(true, double_type.bare_equal(1.6.get_type_info()))
assert_equal(true, float_type.bare_equal(1.6f.get_type_info()))
assert_equal(true, long_double_type.bare_equal(1.6l.get_type_info()))

View File

@ -0,0 +1 @@
assert_equal("3ab", "123abab".substr(2,3))