*** empty log message ***
[luabind.git] / test / test_iterator.cpp
blobd0ce6ba8acc3fef8c3fb1c28ef4d1eda5863c4a0
1 #include "test.h"
3 extern "C"
5 #include "lauxlib.h"
6 #include "lualib.h"
9 #include <vector>
10 #include <luabind/iterator_policy.hpp>
12 namespace
14 LUABIND_ANONYMOUS_FIX int feedback = 0;
16 struct IteratorTest
18 IteratorTest()
20 names.push_back("first one");
21 names.push_back("foobar");
22 names.push_back("last one");
25 std::vector<std::string> names;
28 } // anonymous namespace
30 bool test_iterator()
32 using namespace luabind;
34 lua_State* L = lua_open();
35 lua_baselibopen(L);
36 lua_closer c(L);
38 open(L);
40 class_<IteratorTest>(L, "A")
41 .def(constructor<>())
42 .def_readonly("names", &IteratorTest::names, return_stl_iterator)
45 dostring(L, "a = A()");
46 dostring(L, "b = ''");
47 dostring(L, "for name in a.names do b = b .. name end");
49 if (object_cast<std::string>(get_globals(L)["b"]) != "first onefoobarlast one") return false;
51 return true;