This commit is contained in:
Alexander Bock
2018-02-25 00:31:58 -05:00
55 changed files with 2574 additions and 202 deletions

View File

@@ -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"

View File

@@ -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 <code>true</code> if a call to #option would return a valid Option
*/
bool hasOption() const;
/**
* Returns the currently selected option.
* \return The currently selected option

View File

@@ -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<glm::dmat2x2>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::dmat2x2>::value; ++j) {
lua_pushnumber(state, value[i][j]);
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::dmat2x3>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::dmat2x3>::value; ++j) {
lua_pushnumber(state, value[i][j]);
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::dmat2x4>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::dmat2x4>::value; ++j) {
lua_pushnumber(state, value[i][j]);
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::dmat3x3>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::dmat3x3>::value; ++j) {
lua_pushnumber(state, value[i][j]);
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::dmat3x2>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::dmat3x2>::value; ++j) {
lua_pushnumber(state, value[i][j]);
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::dmat3x4>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::dmat3x4>::value; ++j) {
lua_pushnumber(state, value[i][j]);
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::dmat4x4>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::dmat4x4>::value; ++j) {
lua_pushnumber(state, value[i][j]);
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::dmat4x2>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::dmat4x2>::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<glm::dmat4x2::value_type>(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<glm::dmat4x2>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::dmat4x2>::value; ++j) {
lua_pushnumber(state, value[i][j]);
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::dmat4x3>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::dmat4x3>::value; ++j) {
lua_pushnumber(state, value[i][j]);
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -47,13 +47,16 @@ glm::mat2x2 fromLuaConversion(lua_State* state, bool& success) {
success = false;
return glm::mat2x2(0);
} else {
result[i][j]
= static_cast<glm::mat2x2::value_type>(lua_tonumber(state, -1));
result[i][j] = static_cast<glm::mat2x2::value_type>(
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<glm::mat2x2>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::mat2x2>::value; ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::mat2x3>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::mat2x3>::value; ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::mat2x4>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::mat2x4>::value; ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::mat3x3>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::mat3x3>::value; ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::mat3x2>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::mat3x2>::value; ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::mat3x4>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::mat3x4>::value; ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::mat4x4>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::mat4x4>::value; ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::mat4x2>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::mat4x2>::value; ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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<glm::mat4x3>::value; ++i) {
for (glm::length_t j = 0; j < ghoul::glm_rows<glm::mat4x3>::value; ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
}

View File

@@ -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()];
}

View File

@@ -34,7 +34,9 @@ namespace {
char fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<char>(lua_tonumber(state, -1));
char val = static_cast<char>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return char(0);

View File

@@ -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;

View File

@@ -34,7 +34,9 @@ namespace {
float fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<float>(lua_tonumber(state, -1));
float val = static_cast<float>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0.f;

View File

@@ -34,7 +34,9 @@ namespace {
int fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<int>(lua_tonumber(state, -1));
int val = static_cast<int>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0;

View File

@@ -34,7 +34,9 @@ namespace {
long double fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<long double>(lua_tonumber(state, -1));
long double val = static_cast<long double>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0l;

View File

@@ -34,7 +34,9 @@ namespace {
long long fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<long long>(lua_tonumber(state, -1));
long long val = static_cast<long long>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0;

View File

@@ -34,7 +34,9 @@ namespace {
long fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<long>(lua_tonumber(state, -1));
long val = static_cast<long>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0;

View File

@@ -34,7 +34,9 @@ namespace {
short fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<short>(lua_tonumber(state, -1));
short val = static_cast<short>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0;

View File

@@ -34,7 +34,9 @@ namespace {
signed char fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<signed char>(lua_tonumber(state, -1));
signed char val = static_cast<signed char>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0;

View File

@@ -34,7 +34,9 @@ namespace {
unsigned char fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<unsigned char>(lua_tonumber(state, -1));
unsigned char val = static_cast<unsigned char>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0;

View File

@@ -34,7 +34,9 @@ namespace {
unsigned int fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<unsigned int>(lua_tonumber(state, -1));
unsigned int val = static_cast<unsigned int>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0;

View File

@@ -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<unsigned long long>(lua_tonumber(state, -1));
unsigned long long val = static_cast<unsigned long long>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0ull;

View File

@@ -34,7 +34,9 @@ namespace {
unsigned long fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<unsigned long>(lua_tonumber(state, -1));
unsigned long val = static_cast<unsigned long>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0ul;

View File

@@ -34,7 +34,9 @@ namespace {
unsigned short fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
return static_cast<unsigned short>(lua_tonumber(state, -1));
unsigned short val = static_cast<unsigned short>(lua_tonumber(state, -1));
lua_pop(state, 1);
return val;
}
else {
return 0;

View File

@@ -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<glm::dvec2>::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;

View File

@@ -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<glm::dvec3>::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;

View File

@@ -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<glm::dvec4>::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;

View File

@@ -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<glm::ivec2>::value; ++i) {
lua_pushnumber(state, static_cast<lua_Number>(value[i]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
return true;

View File

@@ -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<glm::ivec3>::value; ++i) {
lua_pushnumber(state, static_cast<lua_Number>(value[i]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
return true;

View File

@@ -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<glm::ivec4>::value; ++i) {
lua_pushnumber(state, static_cast<lua_Number>(value[i]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
return true;

View File

@@ -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<glm::uvec2>::value; ++i) {
lua_pushnumber(state, static_cast<lua_Number>(value[i]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
return true;

View File

@@ -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<glm::uvec3>::value; ++i) {
lua_pushnumber(state, static_cast<lua_Number>(value[i]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
return true;

View File

@@ -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<glm::uvec4>::value; ++i) {
lua_pushnumber(state, static_cast<lua_Number>(value[i]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
return true;

View File

@@ -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<glm::vec2>::value; ++i) {
lua_pushnumber(state, static_cast<lua_Number>(value[i]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
return true;

View File

@@ -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<glm::vec3>::value; ++i) {
lua_pushnumber(state, static_cast<lua_Number>(value[i]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
return true;

View File

@@ -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<glm::vec4>::value; ++i) {
lua_pushnumber(state, static_cast<lua_Number>(value[i]));
lua_setfield(state, -2, std::to_string(number).c_str());
lua_rawseti(state, -2, number);
++number;
}
return true;

View File

@@ -48,57 +48,51 @@
#define GHL_THROW_ON_ASSERT
#endif // GHL_THROW_ON_ASSERTGHL_THROW_ON_ASSERT
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/util/factorymanager.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/time.h>
#include <ghoul/cmdparser/cmdparser>
#include <ghoul/filesystem/filesystem>
#include <ghoul/logging/logging>
#include <ghoul/misc/dictionary.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/misc/dictionary.h>
#include <iostream>
// test files
#include <test_common.inl>
#include <test_spicemanager.inl>
#include <test_assetloader.inl>
#include <test_documentation.inl>
#include <test_luaconversions.inl>
#include <test_optionproperty.inl>
#include <test_powerscalecoordinates.inl>
#include <test_scriptscheduler.inl>
#include <test_spicemanager.inl>
#include <test_timeline.inl>
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
//#include <test_chunknode.inl>
#include <test_lrucache.inl>
#include <test_aabb.inl>
#include <test_angle.inl>
//#include <test_latlonpatch.inl>
#include <test_gdalwms.inl>
//#include <test_patchcoverageprovider.inl>
#include <test_concurrentqueue.inl>
#include <test_concurrentjobmanager.inl>
#include <test_concurrentqueue.inl>
#include <test_lrucache.inl>
#include <test_gdalwms.inl>
#endif
#include <test_luaconversions.inl>
#include <test_powerscalecoordinates.inl>
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
#include <test_screenspaceimage.inl>
//#include <test_iswamanager.inl>
#endif
#ifdef OPENSPACE_MODULE_VOLUME_ENABLED
#include <test_rawvolumeio.inl>
#endif
#include <test_scriptscheduler.inl>
// Regression tests
#include <regression/517.inl>
#include <test_documentation.inl>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/util/factorymanager.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/time.h>
#include <iostream>
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<openspace::WindowWrapper>(), args, close, consoleLog);
openspace::OpenSpaceEngine::create(
argc,
argv,
std::make_unique<openspace::WindowWrapper>(),
args,
close,
consoleLog
);
FileSys.registerPathToken("${TESTDIR}" , "${BASE}/tests");
// All of the relevant tests initialize the SpiceManager
openspace::SpiceManager::deinitialize();
}
testing::InitGoogleTest(&argc, argv);

44
tests/regression/517.inl Normal file
View File

@@ -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 <openspace/properties/optionproperty.h>
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);
}

View File

@@ -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");
}

View File

@@ -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;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,224 @@
/*****************************************************************************************
* *
* 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 <openspace/properties/optionproperty.h>
using namespace openspace::properties;
class OptionPropertyTest : public testing::Test {};
TEST_F(OptionPropertyTest, NoOption) {
OptionProperty p({ "id", "gui", "desc" });
ASSERT_EQ(false, p.hasOption());
}
TEST_F(OptionPropertyTest, SingleOptionSingleZero) {
OptionProperty p({ "id", "gui", "desc"});
p.addOption(0, "a");
p = 0;
ASSERT_EQ(0, p.option().value);
ASSERT_EQ("a", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionSingleNegative) {
OptionProperty p({ "id", "gui", "desc" });
p.addOption(-1, "a");
p = -1;
ASSERT_EQ(-1, p.option().value);
ASSERT_EQ("a", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionSinglePositive) {
OptionProperty p({ "id", "gui", "desc" });
p.addOptions({
{ 1, "a" }
});
p = 1;
ASSERT_EQ(1, p.option().value);
ASSERT_EQ("a", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionMultipleZero) {
OptionProperty p({ "id", "gui", "desc" });
p.addOptions({
{ 0, "a" }
});
p = 0;
ASSERT_EQ(0, p.option().value);
ASSERT_EQ("a", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionMultipleNegative) {
OptionProperty p({ "id", "gui", "desc" });
p.addOptions({
{ -1, "a" }
});
p = -1;
ASSERT_EQ(-1, p.option().value);
ASSERT_EQ("a", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionMultiplePositive) {
OptionProperty p({ "id", "gui", "desc" });
p.addOptions({
{ 1, "a" }
});
p = 1;
ASSERT_EQ(1, p.option().value);
ASSERT_EQ("a", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionsZeroBasedConsecutive) {
OptionProperty p({ "id", "gui", "desc" });
p.addOption(0, "a");
p.addOption(1, "b");
p.addOption(2, "c");
p = 0;
ASSERT_EQ(0, p.option().value);
ASSERT_EQ("a", p.option().description);
p = 1;
ASSERT_EQ(1, p.option().value);
ASSERT_EQ("b", p.option().description);
p = 2;
ASSERT_EQ(2, p.option().value);
ASSERT_EQ("c", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionsZeroBasedNonConsecutive) {
OptionProperty p({ "id", "gui", "desc" });
p.addOption(0, "a");
p.addOption(2, "b");
p.addOption(4, "c");
p = 0;
ASSERT_EQ(0, p.option().value);
ASSERT_EQ("a", p.option().description);
p = 2;
ASSERT_EQ(2, p.option().value);
ASSERT_EQ("b", p.option().description);
p = 4;
ASSERT_EQ(4, p.option().value);
ASSERT_EQ("c", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionsNegativeBasedConsecutive) {
OptionProperty p({ "id", "gui", "desc" });
p.addOption(-1, "a");
p.addOption(-2, "b");
p.addOption(-3, "c");
p = -1;
ASSERT_EQ(-1, p.option().value);
ASSERT_EQ("a", p.option().description);
p = -2;
ASSERT_EQ(-2, p.option().value);
ASSERT_EQ("b", p.option().description);
p = -3;
ASSERT_EQ(-3, p.option().value);
ASSERT_EQ("c", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionsNonZeroBasedNonConsecutive) {
OptionProperty p({ "id", "gui", "desc" });
p.addOption(-1, "a");
p.addOption(-3, "b");
p.addOption(-5, "c");
p = -1;
ASSERT_EQ(-1, p.option().value);
ASSERT_EQ("a", p.option().description);
p = -3;
ASSERT_EQ(-3, p.option().value);
ASSERT_EQ("b", p.option().description);
p = -5;
ASSERT_EQ(-5, p.option().value);
ASSERT_EQ("c", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionsZeroBasedAlternating) {
OptionProperty p({ "id", "gui", "desc" });
p.addOption(0, "a");
p.addOption(2, "b");
p.addOption(-4, "c");
p = 0;
ASSERT_EQ(0, p.option().value);
ASSERT_EQ("a", p.option().description);
p = 2;
ASSERT_EQ(2, p.option().value);
ASSERT_EQ("b", p.option().description);
p = -4;
ASSERT_EQ(-4, p.option().value);
ASSERT_EQ("c", p.option().description);
}
TEST_F(OptionPropertyTest, SingleOptionsNonZeroBasedAlternating) {
OptionProperty p({ "id", "gui", "desc" });
p.addOption(-20, "a");
p.addOption(2, "b");
p.addOption(-10, "c");
p = -20;
ASSERT_EQ(-20, p.option().value);
ASSERT_EQ("a", p.option().description);
p = 2;
ASSERT_EQ(2, p.option().value);
ASSERT_EQ("b", p.option().description);
p = -10;
ASSERT_EQ(-10, p.option().value);
ASSERT_EQ("c", p.option().description);
}

View File

@@ -37,7 +37,7 @@ protected:
void SetUp() override {
openspace::SpiceManager::initialize();
openspace::SpiceManager::ref().loadKernel(
"${TESTDIR}/SpiceTest/spicekernels/naif0008.tls"
absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls")
);
}

View File

@@ -58,47 +58,47 @@ namespace spicemanager_constants {
void loadMetaKernel() {
int k1 = openspace::SpiceManager::ref().loadKernel(
("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls")
absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls")
);
EXPECT_EQ(1, k1) << "loadKernel did not return proper id";
int k2 = openspace::SpiceManager::ref().loadKernel(
("${TESTDIR}/SpiceTest/spicekernels/cas00084.tsc")
absPath("${TESTDIR}/SpiceTest/spicekernels/cas00084.tsc")
);
EXPECT_EQ(2, k2) << "loadKernel did not return proper id";
int k3 = openspace::SpiceManager::ref().loadKernel(
("${TESTDIR}/SpiceTest/spicekernels/981005_PLTEPH-DE405S.bsp")
absPath("${TESTDIR}/SpiceTest/spicekernels/981005_PLTEPH-DE405S.bsp")
);
EXPECT_EQ(3, k3) << "loadKernel did not return proper id";
int k4 = openspace::SpiceManager::ref().loadKernel(
("${TESTDIR}/SpiceTest/spicekernels/020514_SE_SAT105.bsp")
absPath("${TESTDIR}/SpiceTest/spicekernels/020514_SE_SAT105.bsp")
);
EXPECT_EQ(4, k4) << "loadKernel did not return proper id";
int k5 = openspace::SpiceManager::ref().loadKernel(
("${TESTDIR}/SpiceTest/spicekernels/030201AP_SK_SM546_T45.bsp")
absPath("${TESTDIR}/SpiceTest/spicekernels/030201AP_SK_SM546_T45.bsp")
);
EXPECT_EQ(5, k5) << "loadKernel did not return proper id";
int k6 = openspace::SpiceManager::ref().loadKernel(
("${TESTDIR}/SpiceTest/spicekernels/cas_v37.tf")
absPath("${TESTDIR}/SpiceTest/spicekernels/cas_v37.tf")
);
EXPECT_EQ(6, k6) << "loadKernel did not return proper id";
int k7 = openspace::SpiceManager::ref().loadKernel(
("${TESTDIR}/SpiceTest/spicekernels/04135_04171pc_psiv2.bc")
absPath("${TESTDIR}/SpiceTest/spicekernels/04135_04171pc_psiv2.bc")
);
EXPECT_EQ(7, k7) << "loadKernel did not return proper id";
int k8 = openspace::SpiceManager::ref().loadKernel(
("${TESTDIR}/SpiceTest/spicekernels/cpck05Mar2004.tpc")
absPath("${TESTDIR}/SpiceTest/spicekernels/cpck05Mar2004.tpc")
);
EXPECT_EQ(8, k8) << "loadKernel did not return proper id";
int k9 = openspace::SpiceManager::ref().loadKernel(
("${TESTDIR}/SpiceTest/spicekernels/cas_iss_v09.ti")
absPath("${TESTDIR}/SpiceTest/spicekernels/cas_iss_v09.ti")
);
EXPECT_EQ(9, k9) << "loadKernel did not return proper id";
}