#include #include #include TEST_CASE("Path") { luwra::StateWrapper state; REQUIRE(state.runString("value = 1337") == LUA_OK); luwra::internal::Path path {state, "value"}; REQUIRE(luwra::push(state, path) == 1); REQUIRE(luwra::read(state, -1) == 1337); REQUIRE(path.read(state) == 1337); REQUIRE(lua_gettop(state) == 1); path.write(state, 13.37); REQUIRE(luwra::push(state, path) == 1); REQUIRE(luwra::read(state, -1) == 13.37); REQUIRE(path.read(state) == 13.37); REQUIRE(lua_gettop(state) == 2); } TEST_CASE("Path") { luwra::StateWrapper state; REQUIRE(state.runString("value = 1337") == LUA_OK); luwra::internal::Path path {state.ref, "value"}; REQUIRE(luwra::push(state, path) == 1); REQUIRE(luwra::read(state, -1) == 1337); REQUIRE(path.read(state) == 1337); REQUIRE(lua_gettop(state) == 1); path.write(state, 13.37); REQUIRE(luwra::push(state, path) == 1); REQUIRE(luwra::read(state, -1) == 13.37); REQUIRE(path.read(state) == 13.37); REQUIRE(lua_gettop(state) == 2); } TEST_CASE("Path, string>") { luwra::StateWrapper state; REQUIRE(state.runString("value = {field = 1337}") == LUA_OK); luwra::internal::Path< luwra::internal::Path< luwra::Reference, std::string >, std::string > path {{state.ref, "value"}, "field"}; REQUIRE(luwra::push(state, path) == 1); REQUIRE(luwra::read(state, -1) == 1337); REQUIRE(path.read(state) == 1337); REQUIRE(lua_gettop(state) == 1); path.write(state, 13.37); REQUIRE(luwra::push(state, path) == 1); REQUIRE(luwra::read(state, -1) == 13.37); REQUIRE(path.read(state) == 13.37); REQUIRE(lua_gettop(state) == 2); REQUIRE(state.runString("return value.field") == LUA_OK); REQUIRE(luwra::read(state, -1) == 13.37); }