diff --git a/CMakeLists.txt b/CMakeLists.txt
index c73f31f0f6..4f8b955a6f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -230,6 +230,8 @@ if (OPENSPACE_HAVE_TESTS)
)
target_link_libraries(OpenSpaceTest gtest libOpenSpace)
+ set_property(TARGET OpenSpaceTest PROPERTY FOLDER "Unit Tests")
+
if (MSVC)
set_target_properties(OpenSpaceTest PROPERTIES LINK_FLAGS
"/NODEFAULTLIB:LIBCMTD.lib /NODEFAULTLIB:LIBCMT.lib"
diff --git a/include/openspace/properties/optionproperty.h b/include/openspace/properties/optionproperty.h
index 1ab8db03ba..f2945d6b83 100644
--- a/include/openspace/properties/optionproperty.h
+++ b/include/openspace/properties/optionproperty.h
@@ -122,6 +122,13 @@ public:
*/
void setValue(int value) override;
+ /**
+ * This method returns \c true if currently a valid option is selected. This might
+ * change as options are added or removed.
+ * \return true if a call to #option would return a valid Option
+ */
+ bool hasOption() const;
+
/**
* Returns the currently selected option.
* \return The currently selected option
diff --git a/src/properties/matrix/dmat2property.cpp b/src/properties/matrix/dmat2property.cpp
index 11b26cda09..2b08b95d56 100644
--- a/src/properties/matrix/dmat2property.cpp
+++ b/src/properties/matrix/dmat2property.cpp
@@ -54,6 +54,8 @@ glm::dmat2x2 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::dmat2x2 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, value[i][j]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/dmat2x3property.cpp b/src/properties/matrix/dmat2x3property.cpp
index b32a125090..663a52f6f3 100644
--- a/src/properties/matrix/dmat2x3property.cpp
+++ b/src/properties/matrix/dmat2x3property.cpp
@@ -54,6 +54,8 @@ glm::dmat2x3 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::dmat2x3 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, value[i][j]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/dmat2x4property.cpp b/src/properties/matrix/dmat2x4property.cpp
index 5189eecd90..fd56c94b7b 100644
--- a/src/properties/matrix/dmat2x4property.cpp
+++ b/src/properties/matrix/dmat2x4property.cpp
@@ -54,6 +54,8 @@ glm::dmat2x4 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::dmat2x4 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, value[i][j]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/dmat3property.cpp b/src/properties/matrix/dmat3property.cpp
index e236d6eba1..5cf23f3ecd 100644
--- a/src/properties/matrix/dmat3property.cpp
+++ b/src/properties/matrix/dmat3property.cpp
@@ -54,6 +54,8 @@ glm::dmat3x3 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::dmat3x3 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, value[i][j]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/dmat3x2property.cpp b/src/properties/matrix/dmat3x2property.cpp
index 4326635578..3181893074 100644
--- a/src/properties/matrix/dmat3x2property.cpp
+++ b/src/properties/matrix/dmat3x2property.cpp
@@ -54,6 +54,8 @@ glm::dmat3x2 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::dmat3x2 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, value[i][j]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/dmat3x4property.cpp b/src/properties/matrix/dmat3x4property.cpp
index 3fa1419785..b2a2a04cc3 100644
--- a/src/properties/matrix/dmat3x4property.cpp
+++ b/src/properties/matrix/dmat3x4property.cpp
@@ -54,6 +54,8 @@ glm::dmat3x4 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::dmat3x4 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, value[i][j]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/dmat4property.cpp b/src/properties/matrix/dmat4property.cpp
index 793594572b..65b8f00410 100644
--- a/src/properties/matrix/dmat4property.cpp
+++ b/src/properties/matrix/dmat4property.cpp
@@ -54,6 +54,8 @@ glm::dmat4x4 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::dmat4x4 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, value[i][j]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/dmat4x2property.cpp b/src/properties/matrix/dmat4x2property.cpp
index bbf556403e..afd643184d 100644
--- a/src/properties/matrix/dmat4x2property.cpp
+++ b/src/properties/matrix/dmat4x2property.cpp
@@ -34,20 +34,29 @@ namespace {
glm::dmat4x2 fromLuaConversion(lua_State* state, bool& success) {
glm::dmat4x2 result;
+ lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
- lua_getfield(state, -1, std::to_string(number).c_str());
+ int hasNext = lua_next(state, -2);
+ if (hasNext != 1) {
+ success = false;
+ return glm::dmat4x2(0);
+ }
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::dmat4x2(0);
- } else {
- result[i][j] = lua_tonumber(state, -1);
+ }
+ else {
+ result[i][j]
+ = static_cast(lua_tonumber(state, -1));
lua_pop(state, 1);
++number;
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -58,7 +67,7 @@ bool toLuaConversion(lua_State* state, glm::dmat4x2 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, value[i][j]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/dmat4x3property.cpp b/src/properties/matrix/dmat4x3property.cpp
index 247677ad2d..36e84fe4e0 100644
--- a/src/properties/matrix/dmat4x3property.cpp
+++ b/src/properties/matrix/dmat4x3property.cpp
@@ -53,6 +53,8 @@ glm::dmat4x3 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -63,7 +65,7 @@ bool toLuaConversion(lua_State* state, glm::dmat4x3 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, value[i][j]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/mat2property.cpp b/src/properties/matrix/mat2property.cpp
index 7f7a702e30..1751a05e43 100644
--- a/src/properties/matrix/mat2property.cpp
+++ b/src/properties/matrix/mat2property.cpp
@@ -47,13 +47,16 @@ glm::mat2x2 fromLuaConversion(lua_State* state, bool& success) {
success = false;
return glm::mat2x2(0);
} else {
- result[i][j]
- = static_cast(lua_tonumber(state, -1));
+ result[i][j] = static_cast(
+ lua_tonumber(state, -1)
+ );
lua_pop(state, 1);
++number;
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +67,7 @@ bool toLuaConversion(lua_State* state, glm::mat2x2 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, static_cast(value[i][j]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/mat2x3property.cpp b/src/properties/matrix/mat2x3property.cpp
index 0b55352a18..ccc72e9111 100644
--- a/src/properties/matrix/mat2x3property.cpp
+++ b/src/properties/matrix/mat2x3property.cpp
@@ -57,6 +57,8 @@ glm::mat2x3 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -67,7 +69,7 @@ bool toLuaConversion(lua_State* state, glm::mat2x3 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, static_cast(value[i][j]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/mat2x4property.cpp b/src/properties/matrix/mat2x4property.cpp
index f99bee1802..c6a61afb34 100644
--- a/src/properties/matrix/mat2x4property.cpp
+++ b/src/properties/matrix/mat2x4property.cpp
@@ -55,6 +55,8 @@ glm::mat2x4 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -65,7 +67,7 @@ bool toLuaConversion(lua_State* state, glm::mat2x4 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, static_cast(value[i][j]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/mat3property.cpp b/src/properties/matrix/mat3property.cpp
index 7bce40c406..e571c9f5d7 100644
--- a/src/properties/matrix/mat3property.cpp
+++ b/src/properties/matrix/mat3property.cpp
@@ -54,6 +54,8 @@ glm::mat3x3 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::mat3x3 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, static_cast(value[i][j]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/mat3x2property.cpp b/src/properties/matrix/mat3x2property.cpp
index 0c55f45a8e..2398de47c7 100644
--- a/src/properties/matrix/mat3x2property.cpp
+++ b/src/properties/matrix/mat3x2property.cpp
@@ -54,6 +54,8 @@ glm::mat3x2 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::mat3x2 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, static_cast(value[i][j]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/mat3x4property.cpp b/src/properties/matrix/mat3x4property.cpp
index adb40acadd..e175cf0884 100644
--- a/src/properties/matrix/mat3x4property.cpp
+++ b/src/properties/matrix/mat3x4property.cpp
@@ -54,6 +54,8 @@ glm::mat3x4 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::mat3x4 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, static_cast(value[i][j]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/mat4property.cpp b/src/properties/matrix/mat4property.cpp
index 84e04a849c..1c7bb75602 100644
--- a/src/properties/matrix/mat4property.cpp
+++ b/src/properties/matrix/mat4property.cpp
@@ -56,6 +56,8 @@ glm::mat4x4 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -66,7 +68,7 @@ bool toLuaConversion(lua_State* state, glm::mat4x4 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, static_cast(value[i][j]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/mat4x2property.cpp b/src/properties/matrix/mat4x2property.cpp
index 6148f5e952..74ff32121c 100644
--- a/src/properties/matrix/mat4x2property.cpp
+++ b/src/properties/matrix/mat4x2property.cpp
@@ -54,6 +54,8 @@ glm::mat4x2 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::mat4x2 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, static_cast(value[i][j]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/matrix/mat4x3property.cpp b/src/properties/matrix/mat4x3property.cpp
index 8a768a0b4a..e67e14fc27 100644
--- a/src/properties/matrix/mat4x3property.cpp
+++ b/src/properties/matrix/mat4x3property.cpp
@@ -54,6 +54,8 @@ glm::mat4x3 fromLuaConversion(lua_State* state, bool& success) {
}
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -64,7 +66,7 @@ bool toLuaConversion(lua_State* state, glm::mat4x3 value) {
for (glm::length_t i = 0; i < ghoul::glm_cols::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows::value; ++j) {
lua_pushnumber(state, static_cast(value[i][j]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
}
diff --git a/src/properties/optionproperty.cpp b/src/properties/optionproperty.cpp
index 8fb89d3696..169118d93d 100644
--- a/src/properties/optionproperty.cpp
+++ b/src/properties/optionproperty.cpp
@@ -95,6 +95,11 @@ void OptionProperty::setValue(int value) {
LERROR("Could not find an option for value '" << value << "' in OptionProperty");
}
+bool OptionProperty::hasOption() const {
+ return value() >= 0 && value() < _options.size();
+}
+
+
const OptionProperty::Option& OptionProperty::option() const {
return _options[value()];
}
diff --git a/src/properties/scalar/charproperty.cpp b/src/properties/scalar/charproperty.cpp
index f11a33b602..1e247a746c 100644
--- a/src/properties/scalar/charproperty.cpp
+++ b/src/properties/scalar/charproperty.cpp
@@ -34,7 +34,9 @@ namespace {
char fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ char val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return char(0);
diff --git a/src/properties/scalar/doubleproperty.cpp b/src/properties/scalar/doubleproperty.cpp
index 3d15bb635e..d9c1971558 100644
--- a/src/properties/scalar/doubleproperty.cpp
+++ b/src/properties/scalar/doubleproperty.cpp
@@ -34,7 +34,9 @@ namespace {
double fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return lua_tonumber(state, -1);
+ double val = lua_tonumber(state, -1);
+ lua_pop(state, 1);
+ return val;
}
else {
return 0.0;
diff --git a/src/properties/scalar/floatproperty.cpp b/src/properties/scalar/floatproperty.cpp
index 859aeec7f6..27de379ec3 100644
--- a/src/properties/scalar/floatproperty.cpp
+++ b/src/properties/scalar/floatproperty.cpp
@@ -34,7 +34,9 @@ namespace {
float fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ float val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0.f;
diff --git a/src/properties/scalar/intproperty.cpp b/src/properties/scalar/intproperty.cpp
index 4c29cf668b..675e9c8379 100644
--- a/src/properties/scalar/intproperty.cpp
+++ b/src/properties/scalar/intproperty.cpp
@@ -34,7 +34,9 @@ namespace {
int fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ int val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0;
diff --git a/src/properties/scalar/longdoubleproperty.cpp b/src/properties/scalar/longdoubleproperty.cpp
index 12be311787..fb1229522d 100644
--- a/src/properties/scalar/longdoubleproperty.cpp
+++ b/src/properties/scalar/longdoubleproperty.cpp
@@ -34,7 +34,9 @@ namespace {
long double fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ long double val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0l;
diff --git a/src/properties/scalar/longlongproperty.cpp b/src/properties/scalar/longlongproperty.cpp
index 32ac3b28bf..3fa2700c8c 100644
--- a/src/properties/scalar/longlongproperty.cpp
+++ b/src/properties/scalar/longlongproperty.cpp
@@ -34,7 +34,9 @@ namespace {
long long fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ long long val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0;
diff --git a/src/properties/scalar/longproperty.cpp b/src/properties/scalar/longproperty.cpp
index 3ba2d7e0b1..57c6344aa4 100644
--- a/src/properties/scalar/longproperty.cpp
+++ b/src/properties/scalar/longproperty.cpp
@@ -34,7 +34,9 @@ namespace {
long fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ long val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0;
diff --git a/src/properties/scalar/shortproperty.cpp b/src/properties/scalar/shortproperty.cpp
index 0a252a4a04..b2b8d8bd34 100644
--- a/src/properties/scalar/shortproperty.cpp
+++ b/src/properties/scalar/shortproperty.cpp
@@ -34,7 +34,9 @@ namespace {
short fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ short val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0;
diff --git a/src/properties/scalar/signedcharproperty.cpp b/src/properties/scalar/signedcharproperty.cpp
index 2e387a4ae5..ab34f455da 100644
--- a/src/properties/scalar/signedcharproperty.cpp
+++ b/src/properties/scalar/signedcharproperty.cpp
@@ -34,7 +34,9 @@ namespace {
signed char fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ signed char val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0;
diff --git a/src/properties/scalar/ucharproperty.cpp b/src/properties/scalar/ucharproperty.cpp
index 540e903623..d8e34420a2 100644
--- a/src/properties/scalar/ucharproperty.cpp
+++ b/src/properties/scalar/ucharproperty.cpp
@@ -34,7 +34,9 @@ namespace {
unsigned char fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ unsigned char val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0;
diff --git a/src/properties/scalar/uintproperty.cpp b/src/properties/scalar/uintproperty.cpp
index 18f78e4792..1d30943755 100644
--- a/src/properties/scalar/uintproperty.cpp
+++ b/src/properties/scalar/uintproperty.cpp
@@ -34,7 +34,9 @@ namespace {
unsigned int fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ unsigned int val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0;
diff --git a/src/properties/scalar/ulonglongproperty.cpp b/src/properties/scalar/ulonglongproperty.cpp
index a15bad7143..023397c584 100644
--- a/src/properties/scalar/ulonglongproperty.cpp
+++ b/src/properties/scalar/ulonglongproperty.cpp
@@ -34,7 +34,9 @@ namespace {
unsigned long long fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ unsigned long long val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0ull;
diff --git a/src/properties/scalar/ulongproperty.cpp b/src/properties/scalar/ulongproperty.cpp
index 5291a85655..27e562c998 100644
--- a/src/properties/scalar/ulongproperty.cpp
+++ b/src/properties/scalar/ulongproperty.cpp
@@ -34,7 +34,9 @@ namespace {
unsigned long fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ unsigned long val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0ul;
diff --git a/src/properties/scalar/ushortproperty.cpp b/src/properties/scalar/ushortproperty.cpp
index 60345eafa1..4420b40787 100644
--- a/src/properties/scalar/ushortproperty.cpp
+++ b/src/properties/scalar/ushortproperty.cpp
@@ -34,7 +34,9 @@ namespace {
unsigned short fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
- return static_cast(lua_tonumber(state, -1));
+ unsigned short val = static_cast(lua_tonumber(state, -1));
+ lua_pop(state, 1);
+ return val;
}
else {
return 0;
diff --git a/src/properties/vector/dvec2property.cpp b/src/properties/vector/dvec2property.cpp
index b3905a80dc..de3d293a7d 100644
--- a/src/properties/vector/dvec2property.cpp
+++ b/src/properties/vector/dvec2property.cpp
@@ -50,6 +50,8 @@ glm::dvec2 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::dvec2 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, value[i]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/dvec3property.cpp b/src/properties/vector/dvec3property.cpp
index 2ca4c0e827..85d5d68b7f 100644
--- a/src/properties/vector/dvec3property.cpp
+++ b/src/properties/vector/dvec3property.cpp
@@ -50,6 +50,8 @@ glm::dvec3 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::dvec3 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, value[i]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/dvec4property.cpp b/src/properties/vector/dvec4property.cpp
index a555bd049e..b465c1c9d1 100644
--- a/src/properties/vector/dvec4property.cpp
+++ b/src/properties/vector/dvec4property.cpp
@@ -50,6 +50,8 @@ glm::dvec4 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::dvec4 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, value[i]);
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/ivec2property.cpp b/src/properties/vector/ivec2property.cpp
index 15b35d3799..616f99fba3 100644
--- a/src/properties/vector/ivec2property.cpp
+++ b/src/properties/vector/ivec2property.cpp
@@ -50,6 +50,8 @@ glm::ivec2 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::ivec2 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, static_cast(value[i]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/ivec3property.cpp b/src/properties/vector/ivec3property.cpp
index dc2e93fcab..023dbca754 100644
--- a/src/properties/vector/ivec3property.cpp
+++ b/src/properties/vector/ivec3property.cpp
@@ -50,6 +50,8 @@ glm::ivec3 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::ivec3 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, static_cast(value[i]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/ivec4property.cpp b/src/properties/vector/ivec4property.cpp
index 45a72a4596..d5a6608031 100644
--- a/src/properties/vector/ivec4property.cpp
+++ b/src/properties/vector/ivec4property.cpp
@@ -50,6 +50,8 @@ glm::ivec4 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::ivec4 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, static_cast(value[i]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/uvec2property.cpp b/src/properties/vector/uvec2property.cpp
index e1bdb0f949..526bf5e2a9 100644
--- a/src/properties/vector/uvec2property.cpp
+++ b/src/properties/vector/uvec2property.cpp
@@ -50,6 +50,8 @@ glm::uvec2 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::uvec2 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, static_cast(value[i]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/uvec3property.cpp b/src/properties/vector/uvec3property.cpp
index d6cb92f525..24164a3e14 100644
--- a/src/properties/vector/uvec3property.cpp
+++ b/src/properties/vector/uvec3property.cpp
@@ -50,6 +50,8 @@ glm::uvec3 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::uvec3 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, static_cast(value[i]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/uvec4property.cpp b/src/properties/vector/uvec4property.cpp
index 9306ff1f59..f218040e9c 100644
--- a/src/properties/vector/uvec4property.cpp
+++ b/src/properties/vector/uvec4property.cpp
@@ -50,6 +50,8 @@ glm::uvec4 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::uvec4 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, static_cast(value[i]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/vec2property.cpp b/src/properties/vector/vec2property.cpp
index f12da692a6..aa57af300c 100644
--- a/src/properties/vector/vec2property.cpp
+++ b/src/properties/vector/vec2property.cpp
@@ -50,6 +50,8 @@ glm::vec2 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::vec2 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, static_cast(value[i]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/vec3property.cpp b/src/properties/vector/vec3property.cpp
index e6600b9246..d0a846838d 100644
--- a/src/properties/vector/vec3property.cpp
+++ b/src/properties/vector/vec3property.cpp
@@ -50,6 +50,8 @@ glm::vec3 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::vec3 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, static_cast(value[i]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/src/properties/vector/vec4property.cpp b/src/properties/vector/vec4property.cpp
index 8d3dc4ad8e..8118df03eb 100644
--- a/src/properties/vector/vec4property.cpp
+++ b/src/properties/vector/vec4property.cpp
@@ -50,6 +50,8 @@ glm::vec4 fromLuaConversion(lua_State* state, bool& success) {
lua_pop(state, 1);
}
}
+ // The last accessor argument and the table are still on the stack
+ lua_pop(state, 2);
success = true;
return result;
}
@@ -59,7 +61,7 @@ bool toLuaConversion(lua_State* state, glm::vec4 value) {
int number = 1;
for (glm::length_t i = 0; i < ghoul::glm_components::value; ++i) {
lua_pushnumber(state, static_cast(value[i]));
- lua_setfield(state, -2, std::to_string(number).c_str());
+ lua_rawseti(state, -2, number);
++number;
}
return true;
diff --git a/tests/main.cpp b/tests/main.cpp
index cbf2f5c82b..7d828d58ed 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -48,57 +48,51 @@
#define GHL_THROW_ON_ASSERT
#endif // GHL_THROW_ON_ASSERTGHL_THROW_ON_ASSERT
+#include
+#include
+#include
+#include
+#include
+#include
#include
#include
#include
-#include
#include
+#include
+#include
-// test files
#include
-#include
#include
+#include
+#include
+#include
+#include
+#include
+#include
#include
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
-//#include
-#include
#include
-
#include
-//#include
-#include
-//#include
-
-#include
#include
+#include
+#include
+#include
#endif
-#include
-#include
-
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
#include
-//#include
#endif
#ifdef OPENSPACE_MODULE_VOLUME_ENABLED
#include
#endif
-#include
+// Regression tests
+#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
using namespace ghoul::cmdparser;
using namespace ghoul::filesystem;
@@ -124,7 +118,18 @@ int main(int argc, char** argv) {
}
if (!skipOsEng) {
- openspace::OpenSpaceEngine::create(argc, argv, std::make_unique(), args, close, consoleLog);
+ openspace::OpenSpaceEngine::create(
+ argc,
+ argv,
+ std::make_unique(),
+ args,
+ close,
+ consoleLog
+ );
+ FileSys.registerPathToken("${TESTDIR}" , "${BASE}/tests");
+
+ // All of the relevant tests initialize the SpiceManager
+ openspace::SpiceManager::deinitialize();
}
testing::InitGoogleTest(&argc, argv);
diff --git a/tests/regression/517.inl b/tests/regression/517.inl
new file mode 100644
index 0000000000..a4a1ecd104
--- /dev/null
+++ b/tests/regression/517.inl
@@ -0,0 +1,44 @@
+/*****************************************************************************************
+ * *
+ * OpenSpace *
+ * *
+ * Copyright (c) 2014-2018 *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this *
+ * software and associated documentation files (the "Software"), to deal in the Software *
+ * without restriction, including without limitation the rights to use, copy, modify, *
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
+ * permit persons to whom the Software is furnished to do so, subject to the following *
+ * conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included in all copies *
+ * or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ ****************************************************************************************/
+
+#include
+
+using namespace openspace::properties;
+
+class Issue527 : public testing::Test {};
+
+TEST_F(Issue527, Regression) {
+ // Error in OptionProperty if values not starting at 0 are used
+
+ OptionProperty p({ "id", "gui", "desc"});
+
+ p.addOptions({
+ {-1, "a" },
+ {-2, "b" }
+ });
+
+
+ p = -1;
+ ASSERT_EQ("a", p.option().description);
+}
diff --git a/tests/test_assetloader.inl b/tests/test_assetloader.inl
index dea709d733..9b0de4f808 100644
--- a/tests/test_assetloader.inl
+++ b/tests/test_assetloader.inl
@@ -102,13 +102,8 @@ int passTest(lua_State* state) {
}
TEST_F(AssetLoaderTest, Assertions) {
- try {
- _assetLoader->add("passassertion");
- }
- catch (const std::exception& e) {
- EXPECT_TRUE(false) << e.what();
- }
- EXPECT_THROW(_assetLoader->add("failassertion"), ghoul::lua::LuaRuntimeException);
+ EXPECT_NO_THROW(_assetLoader->add("passassertion"));
+ EXPECT_NO_THROW(_assetLoader->add("failassertion"));
}
TEST_F(AssetLoaderTest, BasicExportImport) {
@@ -120,7 +115,7 @@ TEST_F(AssetLoaderTest, BasicExportImport) {
}
}
-TEST_F(AssetLoaderTest, AssetFuncitons) {
+TEST_F(AssetLoaderTest, AssetFunctions) {
try {
_assetLoader->add("assetfunctionsexist");
} catch (const std::exception& e) {
@@ -128,7 +123,7 @@ TEST_F(AssetLoaderTest, AssetFuncitons) {
}
}
-TEST_F(AssetLoaderTest, DependencyFuncitons) {
+TEST_F(AssetLoaderTest, DependencyFunctions) {
try {
_assetLoader->add("dependencyfunctionsexist");
}
diff --git a/tests/test_documentation.inl b/tests/test_documentation.inl
index f52201e635..90ae1a3a06 100644
--- a/tests/test_documentation.inl
+++ b/tests/test_documentation.inl
@@ -770,6 +770,7 @@ TEST_F(DocumentationTest, RequiredInOptional) {
EXPECT_EQ(TestResult::Offense::Reason::MissingKey, negativeRes.offenses[0].reason);
}
+// Exhaustive documentations went away, but we are keeping this test just for funsies
TEST_F(DocumentationTest, Exhaustive) {
using namespace openspace::documentation;
@@ -789,22 +790,18 @@ TEST_F(DocumentationTest, Exhaustive) {
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
- ASSERT_EQ(2, negativeRes.offenses.size());
- EXPECT_EQ("False_Int", negativeRes.offenses[0].offender);
- EXPECT_EQ(TestResult::Offense::Reason::ExtraKey, negativeRes.offenses[0].reason);
- EXPECT_EQ("Int", negativeRes.offenses[1].offender);
- EXPECT_EQ(TestResult::Offense::Reason::MissingKey, negativeRes.offenses[1].reason);
+ ASSERT_EQ(1, negativeRes.offenses.size());
+ EXPECT_EQ("Int", negativeRes.offenses[0].offender);
+ EXPECT_EQ(TestResult::Offense::Reason::MissingKey, negativeRes.offenses[0].reason);
ghoul::Dictionary negative2 {
{ "Double", 2.0 }
};
negativeRes = testSpecification(doc, negative2);
EXPECT_FALSE(negativeRes.success);
- ASSERT_EQ(2, negativeRes.offenses.size());
- EXPECT_EQ("Double", negativeRes.offenses[0].offender);
- EXPECT_EQ(TestResult::Offense::Reason::ExtraKey, negativeRes.offenses[0].reason);
- EXPECT_EQ("Int", negativeRes.offenses[1].offender);
- EXPECT_EQ(TestResult::Offense::Reason::MissingKey, negativeRes.offenses[1].reason);
+ ASSERT_EQ(1, negativeRes.offenses.size());
+ EXPECT_EQ("Int", negativeRes.offenses[0].offender);
+ EXPECT_EQ(TestResult::Offense::Reason::MissingKey, negativeRes.offenses[0].reason);
}
TEST_F(DocumentationTest, NestedExhaustive) {
@@ -829,11 +826,9 @@ TEST_F(DocumentationTest, NestedExhaustive) {
};
TestResult negativeRes = testSpecification(doc, negative);
EXPECT_FALSE(negativeRes.success);
- ASSERT_EQ(2, negativeRes.offenses.size());
+ ASSERT_EQ(1, negativeRes.offenses.size());
EXPECT_EQ("Table.a", negativeRes.offenses[0].offender);
EXPECT_EQ(TestResult::Offense::Reason::MissingKey, negativeRes.offenses[0].reason);
- EXPECT_EQ("Table.b", negativeRes.offenses[1].offender);
- EXPECT_EQ(TestResult::Offense::Reason::ExtraKey, negativeRes.offenses[1].reason);
}
TEST_F(DocumentationTest, EmptyEntriesNonExhaustive) {
@@ -876,14 +871,10 @@ TEST_F(DocumentationTest, EmptyNestedExhaustive) {
{ "Table", ghoul::Dictionary{ { "a", 1 }}}
};
TestResult negativeRes = testSpecification(doc, negative);
- EXPECT_FALSE(negativeRes.success);
- ASSERT_EQ(1, negativeRes.offenses.size());
- EXPECT_EQ("Table.a", negativeRes.offenses[0].offender);
- EXPECT_EQ(TestResult::Offense::Reason::ExtraKey, negativeRes.offenses[0].reason);
+ EXPECT_TRUE(negativeRes.success);
+ ASSERT_EQ(0, negativeRes.offenses.size());
}
-
-
TEST_F(DocumentationTest, LessInt) {
using namespace openspace::documentation;
diff --git a/tests/test_luaconversions.inl b/tests/test_luaconversions.inl
index 16fc1ba5cb..a344eefca1 100644
--- a/tests/test_luaconversions.inl
+++ b/tests/test_luaconversions.inl
@@ -29,6 +29,12 @@
#include
#include
+#include
+
+namespace {
+ constexpr int NumberFuzzTests = 100000;
+} // namespace
+
class LuaConversionTest : public testing::Test {
protected:
lua_State* state;
@@ -54,101 +60,2098 @@ TEST_F(LuaConversionTest, LuaExecution) {
EXPECT_EQ(status, LUA_OK);
}
-#define CONVERSION_TEST_TEMPLATE(__NAME__, __TYPE__, __VALUE__) \
- TEST_F(LuaConversionTest, __NAME__) \
- { \
- using namespace openspace::properties; \
- bool success \
- = PropertyDelegate>::toLuaValue<__TYPE__>( \
- state, __VALUE__); \
- EXPECT_TRUE(success) << "toLuaValue"; \
- __TYPE__ value = static_cast<__TYPE__>(0); \
- value = PropertyDelegate>::fromLuaValue<__TYPE__>( \
- state, success); \
- EXPECT_TRUE(success) << "fromLuaValue"; \
- EXPECT_EQ(value, __VALUE__) << "fromLuaValue"; \
- }
-
-#define CONVERSION_TEST_NUMERICAL(__NAME__, __TYPE__, __VALUE__) \
- TEST_F(LuaConversionTest, __NAME__) \
- { \
- using namespace openspace::properties; \
- bool success \
- = PropertyDelegate>::toLuaValue<__TYPE__>( \
- state, __VALUE__); \
- EXPECT_TRUE(success) << "toLuaValue"; \
- __TYPE__ value = static_cast<__TYPE__>(0); \
- value = PropertyDelegate>::fromLuaValue<__TYPE__>( \
- state, success); \
- EXPECT_TRUE(success) << "fromLuaValue"; \
- EXPECT_EQ(value, __VALUE__) << "fromLuaValue"; \
- }
-
-CONVERSION_TEST_TEMPLATE(Bool, bool, true)
-
-CONVERSION_TEST_NUMERICAL(Char, char, 1)
-//CONVERSION_TEST_NUMERICAL(WChar, wchar_t, 1);
-CONVERSION_TEST_NUMERICAL(SignedChar, signed char, 1)
-CONVERSION_TEST_NUMERICAL(UnsignedChar, unsigned char, 1)
-CONVERSION_TEST_NUMERICAL(Short, short, 1)
-CONVERSION_TEST_NUMERICAL(UnsignedShort, unsigned short, 1)
-
-//CONVERSION_TEST_NUMERICAL(Int, int, 1)
-// Need to separate int into its own test as otherwise static_cast(1) would throw a
-// useless cast warning
-TEST_F(LuaConversionTest, Int) {
+TEST_F(LuaConversionTest, Bool) {
using namespace openspace::properties;
- bool success = PropertyDelegate>::toLuaValue(state, 1);
- EXPECT_TRUE(success) << "toLuaValue";
- int value = 0;
- value = PropertyDelegate>::fromLuaValue(state, success);
- EXPECT_TRUE(success) << "fromLuaValue";
- EXPECT_EQ(value, 1) << "fromLuaValue";
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ true
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ bool value = static_cast(0);
+ value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, true) << "fromLuaValue";
}
-CONVERSION_TEST_NUMERICAL(UnsignedInt, unsigned int, 1)
-CONVERSION_TEST_NUMERICAL(Long, long, 1)
-CONVERSION_TEST_NUMERICAL(UnsignedLong, unsigned long, 1)
-CONVERSION_TEST_NUMERICAL(LongLong, long long, 1)
-CONVERSION_TEST_NUMERICAL(UnsignedLongLong, unsigned long long, 1)
-CONVERSION_TEST_NUMERICAL(Float, float, 1.f)
-CONVERSION_TEST_NUMERICAL(Double, double, 1.0)
-CONVERSION_TEST_NUMERICAL(LongDouble, long double, 1.0)
+TEST_F(LuaConversionTest, Char) {
+ using namespace openspace::properties;
+ using T = char;
+ T val = T(1);
-CONVERSION_TEST_NUMERICAL(Vec2, glm::vec2, glm::vec2(1.f))
-CONVERSION_TEST_NUMERICAL(Vec3, glm::vec3, glm::vec3(1.f))
-CONVERSION_TEST_NUMERICAL(Vec4, glm::vec4, glm::vec4(1.f))
-CONVERSION_TEST_NUMERICAL(DVec2, glm::dvec2, glm::dvec2(1.0))
-CONVERSION_TEST_NUMERICAL(DVec3, glm::dvec3, glm::dvec3(1.0))
-CONVERSION_TEST_NUMERICAL(DVec4, glm::dvec4, glm::dvec4(1.0))
-CONVERSION_TEST_NUMERICAL(IVec2, glm::ivec2, glm::ivec2(1))
-CONVERSION_TEST_NUMERICAL(IVec3, glm::ivec3, glm::ivec3(1))
-CONVERSION_TEST_NUMERICAL(IVec4, glm::ivec4, glm::ivec4(1))
-CONVERSION_TEST_NUMERICAL(UVec2, glm::uvec2, glm::uvec2(1))
-CONVERSION_TEST_NUMERICAL(UVec3, glm::uvec3, glm::uvec3(1))
-CONVERSION_TEST_NUMERICAL(UVec4, glm::uvec4, glm::uvec4(1))
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+}
-CONVERSION_TEST_NUMERICAL(Mat2x2, glm::mat2x2, glm::mat2x2(1.f))
-CONVERSION_TEST_NUMERICAL(Mat2x3, glm::mat2x3, glm::mat2x3(1.f))
-CONVERSION_TEST_NUMERICAL(Mat2x4, glm::mat2x4, glm::mat2x4(1.f))
-CONVERSION_TEST_NUMERICAL(Mat3x2, glm::mat3x2, glm::mat3x2(1.f))
-CONVERSION_TEST_NUMERICAL(Mat3x3, glm::mat3x3, glm::mat3x3(1.f))
-CONVERSION_TEST_NUMERICAL(Mat3x4, glm::mat3x4, glm::mat3x4(1.f))
-CONVERSION_TEST_NUMERICAL(Mat4x2, glm::mat4x2, glm::mat4x2(1.f))
-CONVERSION_TEST_NUMERICAL(Mat4x3, glm::mat4x3, glm::mat4x3(1.f))
-CONVERSION_TEST_NUMERICAL(Mat4x4, glm::mat4x4, glm::mat4x4(1.f))
-CONVERSION_TEST_NUMERICAL(DMat2x2, glm::dmat2x2, glm::dmat2x2(1.f))
-CONVERSION_TEST_NUMERICAL(DMat2x3, glm::dmat2x3, glm::dmat2x3(1.f))
-CONVERSION_TEST_NUMERICAL(DMat2x4, glm::dmat2x4, glm::dmat2x4(1.f))
-CONVERSION_TEST_NUMERICAL(DMat3x2, glm::dmat3x2, glm::dmat3x2(1.f))
-CONVERSION_TEST_NUMERICAL(DMat3x3, glm::dmat3x3, glm::dmat3x3(1.f))
-CONVERSION_TEST_NUMERICAL(DMat3x4, glm::dmat3x4, glm::dmat3x4(1.f))
-CONVERSION_TEST_NUMERICAL(DMat4x2, glm::dmat4x2, glm::dmat4x2(1.f))
-CONVERSION_TEST_NUMERICAL(DMat4x3, glm::dmat4x3, glm::dmat4x3(1.f))
-CONVERSION_TEST_NUMERICAL(DMat4x4, glm::dmat4x4, glm::dmat4x4(1.f))
+TEST_F(LuaConversionTest, CharFuzz) {
+ using namespace openspace::properties;
+ using T = char;
-TEST_F(LuaConversionTest, String)
-{
+ std::mt19937 gen(1337);
+ std::uniform_int_distribution<> dis(
+ std::numeric_limits::lowest(),
+ std::numeric_limits::max()
+ );
+
+ for (int i = 0; i < NumberFuzzTests; ++i) {
+ T val = T(dis(gen));
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+ }
+}
+
+//TEST_F(LuaConversionTest, WChar) {
+// using namespace openspace::properties;
+// using T = wchar_t;
+//
+// T val = T(1);
+//
+// bool success = PropertyDelegate>::toLuaValue(
+// state,
+// val
+// );
+// EXPECT_TRUE(success) << "toLuaValue";
+// T value = PropertyDelegate>::fromLuaValue(
+// state,
+// success
+// );
+// EXPECT_TRUE(success) << "fromLuaValue";
+// EXPECT_EQ(value, val) << "fromLuaValue";
+//}
+
+//TEST_F(LuaConversionTest, WCharFuzz) {
+// using namespace openspace::properties;
+// using T = wchar_t;
+//
+// std::mt19937 gen(1337);
+// std::uniform_int_distribution<> dis(
+// std::numeric_limits::lowest(),
+// std::numeric_limits::max()
+// );
+//
+// constexpr int NumberFuzzTests = 10000;
+// for (int i = 0; i < NumberFuzzTests; ++i) {
+// T val = T(dis(gen));
+//
+// bool success = PropertyDelegate>::toLuaValue(
+// state,
+// val
+// );
+// EXPECT_TRUE(success) << "toLuaValue";
+// T value = PropertyDelegate>::fromLuaValue(
+// state,
+// success
+// );
+// EXPECT_TRUE(success) << "fromLuaValue";
+// EXPECT_EQ(value, val) << "fromLuaValue";
+// }
+//}
+
+TEST_F(LuaConversionTest, SignedChar) {
+ using namespace openspace::properties;
+ using T = signed char;
+ T val = T(1);
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+}
+
+TEST_F(LuaConversionTest, SignedCharFuzz) {
+ using namespace openspace::properties;
+ using T = signed char;
+
+ std::mt19937 gen(1337);
+ std::uniform_int_distribution<> dis(
+ std::numeric_limits::lowest(),
+ std::numeric_limits::max()
+ );
+
+ for (int i = 0; i < NumberFuzzTests; ++i) {
+ T val = T(dis(gen));
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+ }
+}
+
+TEST_F(LuaConversionTest, UnsignedChar) {
+ using namespace openspace::properties;
+ using T = unsigned char;
+ T val = T(1);
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+}
+
+TEST_F(LuaConversionTest, UnsignedCharFuzz) {
+ using namespace openspace::properties;
+ using T = unsigned char;
+
+ std::mt19937 gen(1337);
+ std::uniform_int_distribution<> dis(
+ std::numeric_limits::lowest(),
+ std::numeric_limits::max()
+ );
+
+ for (int i = 0; i < NumberFuzzTests; ++i) {
+ T val = T(dis(gen));
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+ }
+}
+
+TEST_F(LuaConversionTest, Short) {
+ using namespace openspace::properties;
+ using T = short;
+ T val = T(1);
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+}
+
+TEST_F(LuaConversionTest, ShortFuzz) {
+ using namespace openspace::properties;
+ using T = short;
+
+ std::mt19937 gen(1337);
+ std::uniform_int_distribution dis(
+ std::numeric_limits::lowest(),
+ std::numeric_limits::max()
+ );
+
+ for (int i = 0; i < NumberFuzzTests; ++i) {
+ T val = T(dis(gen));
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+ }
+}
+
+TEST_F(LuaConversionTest, UnsignedShort) {
+ using namespace openspace::properties;
+ using T = unsigned short;
+ T val = T(1);
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+}
+
+TEST_F(LuaConversionTest, UnsignedShortFuzz) {
+ using namespace openspace::properties;
+ using T = unsigned short;
+
+ std::mt19937 gen(1337);
+ std::uniform_int_distribution dis(
+ std::numeric_limits::lowest(),
+ std::numeric_limits::max()
+ );
+
+ for (int i = 0; i < NumberFuzzTests; ++i) {
+ T val = T(dis(gen));
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+ }
+}
+
+TEST_F(LuaConversionTest, Int) {
+ using namespace openspace::properties;
+ using T = int;
+ T val = T(1);
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+}
+
+TEST_F(LuaConversionTest, IntFuzz) {
+ using namespace openspace::properties;
+ using T = int;
+
+ std::mt19937 gen(1337);
+ std::uniform_int_distribution dis(
+ std::numeric_limits::lowest(),
+ std::numeric_limits::max()
+ );
+
+ for (int i = 0; i < NumberFuzzTests; ++i) {
+ T val = T(dis(gen));
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+ }
+}
+
+TEST_F(LuaConversionTest, UnsignedInt) {
+ using namespace openspace::properties;
+ using T = unsigned int;
+ T val = T(1);
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+}
+
+TEST_F(LuaConversionTest, UnsignedIntFuzz) {
+ using namespace openspace::properties;
+ using T = unsigned int;
+
+ std::mt19937 gen(1337);
+ std::uniform_int_distribution dis(
+ std::numeric_limits::lowest(),
+ std::numeric_limits::max()
+ );
+
+ for (int i = 0; i < NumberFuzzTests; ++i) {
+ T val = T(dis(gen));
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue(
+ state,
+ success
+ );
+ EXPECT_TRUE(success) << "fromLuaValue";
+ EXPECT_EQ(value, val) << "fromLuaValue";
+ }
+}
+
+TEST_F(LuaConversionTest, Long) {
+ using namespace openspace::properties;
+ using T = long;
+ T val = T(1);
+
+ bool success = PropertyDelegate>::toLuaValue(
+ state,
+ val
+ );
+ EXPECT_TRUE(success) << "toLuaValue";
+ T value = PropertyDelegate>::fromLuaValue