*** empty log message ***
[luabind.git] / test / test_iterator.cpp
blob9dabd892d0ddab08f6db48af333bdb9b90f2a6c6
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 module(L)
42 class_<IteratorTest>("A")
43 .def(constructor<>())
44 .def_readonly("names", &IteratorTest::names, return_stl_iterator)
47 dostring(L, "a = A()");
48 dostring(L, "b = ''");
49 dostring(L, "for name in a.names do b = b .. name end");
51 if (object_cast<std::string>(get_globals(L)["b"]) != "first onefoobarlast one") return false;
53 return true;