Przeglądaj źródła

Add test case for FieldVector pushing

Ole 10 lat temu
rodzic
commit
c45d328982
2 zmienionych plików z 19 dodań i 4 usunięć
  1. 15 0
      tests/auxiliary.cpp
  2. 4 4
      tests/types.cpp

+ 15 - 0
tests/auxiliary.cpp

@@ -76,3 +76,18 @@ TEST_CASE("getField") {
 	REQUIRE(luaL_dostring(state, "return {hello = 123}") == LUA_OK);
 	REQUIRE(luwra::getField<int>(state, -1, "hello") == 123);
 }
+
+TEST_CASE("FieldVector") {
+	luwra::StateWrapper state;
+
+	luwra::push<luwra::FieldVector>(state, {
+		{"test", 7331},
+		{7331,   123}
+	});
+
+	lua_setglobal(state, "test");
+
+	REQUIRE(luaL_dostring(state, "return test.test, test[test.test]") == LUA_OK);
+	REQUIRE(luwra::read<int>(state, -2) == 7331);
+	REQUIRE(luwra::read<int>(state, -1) == 123);
+}

+ 4 - 4
tests/types.cpp

@@ -43,7 +43,7 @@ using SelectNumericTest =
 		TautologyTest
 	>::type;
 
-TEST_CASE("types_numeric") {
+TEST_CASE("numeric") {
 	lua_State* state = luaL_newstate();
 
 	// Integer-based types
@@ -66,7 +66,7 @@ TEST_CASE("types_numeric") {
 	lua_close(state);
 }
 
-TEST_CASE("types_string") {
+TEST_CASE("string") {
 	lua_State* state = luaL_newstate();
 
 	const char* test_cstr = "Luwra Test String";
@@ -105,7 +105,7 @@ TEST_CASE("types_string") {
 	lua_close(state);
 }
 
-TEST_CASE("types_tuple") {
+TEST_CASE("tuples") {
 	lua_State* state = luaL_newstate();
 
 	int a = 13;
@@ -123,7 +123,7 @@ TEST_CASE("types_tuple") {
 	lua_close(state);
 }
 
-TEST_CASE("types_bool") {
+TEST_CASE("boolean") {
 	lua_State* state = luaL_newstate();
 
 	bool value = true;