mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Cleanup + formatting
This commit is contained in:
parent
bfe33f64eb
commit
a48adf5ce5
26 changed files with 268 additions and 1402 deletions
139
cmake/macros/SetupHFTestCase.cmake
Normal file
139
cmake/macros/SetupHFTestCase.cmake
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
#
|
||||||
|
# SetupHFTestCase.cmake
|
||||||
|
#
|
||||||
|
# Copyright 2015 High Fidelity, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the Apache License, Version 2.0.
|
||||||
|
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
#
|
||||||
|
|
||||||
|
# Sets up a hifi testcase using QtTest.
|
||||||
|
# Can be called with arguments; like setup_hifi_project, the arguments correspond to qt modules, so call it
|
||||||
|
# via setup_hifi_testcase(Script Network Qml) to build the testcase with Qt5Script, Qt5Network, and Qt5Qml linked,
|
||||||
|
# for example.
|
||||||
|
|
||||||
|
# One special quirk of this is that because we are creating multiple testcase targets (instead of just one),
|
||||||
|
# any dependencies and other setup that the testcase has must be declared in a macro, and setup_hifi_testcase()
|
||||||
|
# must be called *after* this declaration, not before it.
|
||||||
|
|
||||||
|
# Here's a full example:
|
||||||
|
# tests/my-foo-test/CMakeLists.txt:
|
||||||
|
#
|
||||||
|
# # Declare testcase dependencies
|
||||||
|
# macro (setup_hifi_testcase)
|
||||||
|
# bunch
|
||||||
|
# of
|
||||||
|
# custom
|
||||||
|
# dependencies...
|
||||||
|
#
|
||||||
|
# link_hifi_libraries(shared networking etc)
|
||||||
|
#
|
||||||
|
# copy_dlls_beside_windows_executable()
|
||||||
|
# endmacro()
|
||||||
|
#
|
||||||
|
# setup_hifi_testcase(Network etc)
|
||||||
|
#
|
||||||
|
# Additionally, all .cpp files in the src dir (eg tests/my-foo-test/src) must:
|
||||||
|
# - Contain exactly one test class (any supporting code must be either external or inline in a .hpp file)
|
||||||
|
# - Be built against QtTestLib (test class should be a QObject, with test methods defined as private slots)
|
||||||
|
# - Contain a QTEST_MAIN declaration at the end of the file (or at least be a standalone executable)
|
||||||
|
#
|
||||||
|
# All other testing infrastructure is generated automatically.
|
||||||
|
#
|
||||||
|
|
||||||
|
macro(SETUP_HIFI_TESTCASE)
|
||||||
|
if (NOT DEFINED TEST_PROJ_NAME)
|
||||||
|
message(SEND_ERROR "Missing TEST_PROJ_NAME (setup_hifi_testcase was called incorrectly?)")
|
||||||
|
elseif (NOT COMMAND SETUP_TESTCASE_DEPENDENCIES)
|
||||||
|
message(SEND_ERROR "Missing testcase dependencies declaration (SETUP_TESTCASE_DEPENDENCIES)")
|
||||||
|
elseif (DEFINED ${TEST_PROJ_NAME}_BUILT)
|
||||||
|
message(WARNING "testcase \"" ${TEST_PROJ_NAME} "\" was already built")
|
||||||
|
else ()
|
||||||
|
set(${TEST_PROJ_NAME}_BUILT 1)
|
||||||
|
|
||||||
|
file(GLOB TEST_PROJ_SRC_FILES src/*)
|
||||||
|
file(GLOB TEST_PROJ_SRC_SUBDIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/*)
|
||||||
|
|
||||||
|
foreach (DIR ${TEST_PROJ_SRC_SUBDIRS})
|
||||||
|
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/${DIR}")
|
||||||
|
file(GLOB DIR_CONTENTS "src/${DIR}/*")
|
||||||
|
set(TEST_PROJ_SRC_FILES ${TEST_PROJ_SRC_FILES} "${DIR_CONTENTS}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Find test classes to build into test executables.
|
||||||
|
# Warn about any .cpp files that are *not* test classes (*Test[s].cpp), since those files will not be used.
|
||||||
|
foreach (SRC_FILE ${TEST_PROJ_SRC_FILES})
|
||||||
|
string(REGEX MATCH ".+Tests?\\.cpp$" TEST_CPP_FILE ${SRC_FILE})
|
||||||
|
string(REGEX MATCH ".+\\.cpp$" NON_TEST_CPP_FILE ${SRC_FILE})
|
||||||
|
if (TEST_CPP_FILE)
|
||||||
|
list(APPEND TEST_CASE_FILES ${TEST_CPP_FILE})
|
||||||
|
elseif (NON_TEST_CPP_FILE)
|
||||||
|
message(WARNING "ignoring .cpp file (not a test class -- this will not be linked or compiled!): " ${NON_TEST_CPP_FILE})
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
if (TEST_CASE_FILES)
|
||||||
|
set(TEST_PROJ_TARGETS "")
|
||||||
|
|
||||||
|
# Add each test class executable (duplicates functionality in SetupHifiProject.cmake)
|
||||||
|
# The resulting targets will be buried inside of hidden/test-executables so that they don't clutter up
|
||||||
|
# the project view in Xcode, Visual Studio, etc.
|
||||||
|
foreach (TEST_FILE ${TEST_CASE_FILES})
|
||||||
|
get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE)
|
||||||
|
set(TARGET_NAME ${TEST_PROJ_NAME}-${TEST_NAME})
|
||||||
|
|
||||||
|
project(${TARGET_NAME})
|
||||||
|
|
||||||
|
# grab the implemenation and header files
|
||||||
|
set(TARGET_SRCS ${TEST_FILE}) # only one source / .cpp file (the test class)
|
||||||
|
|
||||||
|
add_executable(${TARGET_NAME} ${TEST_FILE})
|
||||||
|
add_test(${TARGET_NAME}-test ${TARGET_NAME})
|
||||||
|
set_target_properties(${TARGET_NAME} PROPERTIES
|
||||||
|
EXCLUDE_FROM_DEFAULT_BUILD TRUE
|
||||||
|
EXCLUDE_FROM_ALL TRUE)
|
||||||
|
|
||||||
|
list (APPEND ${TEST_PROJ_NAME}_TARGETS ${TARGET_NAME})
|
||||||
|
#list (APPEND ALL_TEST_TARGETS ${TARGET_NAME})
|
||||||
|
|
||||||
|
set(${TARGET_NAME}_DEPENDENCY_QT_MODULES ${ARGN})
|
||||||
|
|
||||||
|
list(APPEND ${TARGET_NAME}_DEPENDENCY_QT_MODULES Core Test)
|
||||||
|
|
||||||
|
# find these Qt modules and link them to our own target
|
||||||
|
find_package(Qt5 COMPONENTS ${${TARGET_NAME}_DEPENDENCY_QT_MODULES} REQUIRED)
|
||||||
|
|
||||||
|
foreach(QT_MODULE ${${TARGET_NAME}_DEPENDENCY_QT_MODULES})
|
||||||
|
target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "hidden/test-executables")
|
||||||
|
|
||||||
|
# handle testcase-specific dependencies (this a macro that should be defined in the cmakelists.txt file in each tests subdir)
|
||||||
|
|
||||||
|
SETUP_TESTCASE_DEPENDENCIES ()
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
set(TEST_TARGET ${TEST_PROJ_NAME}-tests)
|
||||||
|
|
||||||
|
# Add a dummy target so that the project files are visible.
|
||||||
|
# This target will also build + run the other test targets using ctest when built.
|
||||||
|
|
||||||
|
add_custom_target(${TEST_TARGET}
|
||||||
|
COMMAND ctest .
|
||||||
|
SOURCES ${TEST_PROJ_SRC_FILES} # display source files under the testcase target
|
||||||
|
DEPENDS ${${TEST_PROJ_NAME}_TARGETS})
|
||||||
|
set_target_properties(${TEST_TARGET} PROPERTIES
|
||||||
|
EXCLUDE_FROM_DEFAULT_BUILD TRUE
|
||||||
|
EXCLUDE_FROM_ALL TRUE)
|
||||||
|
|
||||||
|
set_target_properties(${TEST_TARGET} PROPERTIES FOLDER "Tests")
|
||||||
|
|
||||||
|
list (APPEND ALL_TEST_TARGETS ${TEST_TARGET})
|
||||||
|
set(ALL_TEST_TARGETS "${ALL_TEST_TARGETS}" PARENT_SCOPE)
|
||||||
|
else ()
|
||||||
|
message(WARNING "No testcases in " ${TEST_PROJ_NAME})
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
endmacro(SETUP_HIFI_TESTCASE)
|
|
@ -1,139 +0,0 @@
|
||||||
#
|
|
||||||
# SetupHifiTestCase.cmake
|
|
||||||
#
|
|
||||||
# Copyright 2015 High Fidelity, Inc.
|
|
||||||
#
|
|
||||||
# Distributed under the Apache License, Version 2.0.
|
|
||||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
#
|
|
||||||
|
|
||||||
# Sets up a hifi testcase using QtTest.
|
|
||||||
# Can be called with arguments; like setup_hifi_project, the arguments correspond to qt modules, so call it
|
|
||||||
# via setup_hifi_testcase(Script Network Qml) to build the testcase with Qt5Script, Qt5Network, and Qt5Qml linked,
|
|
||||||
# for example.
|
|
||||||
|
|
||||||
# One special quirk of this is that because we are creating multiple testcase targets (instead of just one),
|
|
||||||
# any dependencies and other setup that the testcase has must be declared in a macro, and setup_hifi_testcase()
|
|
||||||
# must be called *after* this declaration, not before it.
|
|
||||||
|
|
||||||
# Here's a full example:
|
|
||||||
# tests/my-foo-test/CMakeLists.txt:
|
|
||||||
#
|
|
||||||
# # Declare testcase dependencies
|
|
||||||
# macro (setup_hifi_testcase)
|
|
||||||
# bunch
|
|
||||||
# of
|
|
||||||
# custom
|
|
||||||
# dependencies...
|
|
||||||
#
|
|
||||||
# link_hifi_libraries(shared networking etc)
|
|
||||||
#
|
|
||||||
# copy_dlls_beside_windows_executable()
|
|
||||||
# endmacro()
|
|
||||||
#
|
|
||||||
# setup_hifi_testcase(Network etc)
|
|
||||||
#
|
|
||||||
# Additionally, all .cpp files in the src dir (eg tests/my-foo-test/src) must:
|
|
||||||
# - Contain exactly one test class (any supporting code must be either external or inline in a .hpp file)
|
|
||||||
# - Be built against QtTestLib (test class should be a QObject, with test methods defined as private slots)
|
|
||||||
# - Contain a QTEST_MAIN declaration at the end of the file (or at least be a standalone executable)
|
|
||||||
#
|
|
||||||
# All other testing infrastructure is generated automatically.
|
|
||||||
#
|
|
||||||
|
|
||||||
macro(SETUP_HIFI_TESTCASE)
|
|
||||||
if (NOT DEFINED TEST_PROJ_NAME)
|
|
||||||
message(SEND_ERROR "Missing TEST_PROJ_NAME (setup_hifi_testcase was called incorrectly?)")
|
|
||||||
elseif (NOT COMMAND SETUP_TESTCASE_DEPENDENCIES)
|
|
||||||
message(SEND_ERROR "Missing testcase dependencies declaration (SETUP_TESTCASE_DEPENDENCIES)")
|
|
||||||
elseif (DEFINED ${TEST_PROJ_NAME}_BUILT)
|
|
||||||
message(WARNING "testcase \"" ${TEST_PROJ_NAME} "\" was already built")
|
|
||||||
else ()
|
|
||||||
set(${TEST_PROJ_NAME}_BUILT 1)
|
|
||||||
|
|
||||||
file(GLOB TEST_PROJ_SRC_FILES src/*)
|
|
||||||
file(GLOB TEST_PROJ_SRC_SUBDIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/*)
|
|
||||||
|
|
||||||
foreach (DIR ${TEST_PROJ_SRC_SUBDIRS})
|
|
||||||
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/${DIR}")
|
|
||||||
file(GLOB DIR_CONTENTS "src/${DIR}/*")
|
|
||||||
set(TEST_PROJ_SRC_FILES ${TEST_PROJ_SRC_FILES} "${DIR_CONTENTS}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Find test classes to build into test executables.
|
|
||||||
# Warn about any .cpp files that are *not* test classes (*Test[s].cpp), since those files will not be used.
|
|
||||||
foreach (SRC_FILE ${TEST_PROJ_SRC_FILES})
|
|
||||||
string(REGEX MATCH ".+Tests?\\.cpp$" TEST_CPP_FILE ${SRC_FILE})
|
|
||||||
string(REGEX MATCH ".+\\.cpp$" NON_TEST_CPP_FILE ${SRC_FILE})
|
|
||||||
if (TEST_CPP_FILE)
|
|
||||||
list(APPEND TEST_CASE_FILES ${TEST_CPP_FILE})
|
|
||||||
elseif (NON_TEST_CPP_FILE)
|
|
||||||
message(WARNING "ignoring .cpp file (not a test class -- this will not be linked or compiled!): " ${NON_TEST_CPP_FILE})
|
|
||||||
endif ()
|
|
||||||
endforeach ()
|
|
||||||
|
|
||||||
if (TEST_CASE_FILES)
|
|
||||||
set(TEST_PROJ_TARGETS "")
|
|
||||||
|
|
||||||
# Add each test class executable (duplicates functionality in SetupHifiProject.cmake)
|
|
||||||
# The resulting targets will be buried inside of hidden/test-executables so that they don't clutter up
|
|
||||||
# the project view in Xcode, Visual Studio, etc.
|
|
||||||
foreach (TEST_FILE ${TEST_CASE_FILES})
|
|
||||||
get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE)
|
|
||||||
set(TARGET_NAME ${TEST_PROJ_NAME}-${TEST_NAME})
|
|
||||||
|
|
||||||
project(${TARGET_NAME})
|
|
||||||
|
|
||||||
# grab the implemenation and header files
|
|
||||||
set(TARGET_SRCS ${TEST_FILE}) # only one source / .cpp file (the test class)
|
|
||||||
|
|
||||||
add_executable(${TARGET_NAME} ${TEST_FILE})
|
|
||||||
add_test(${TARGET_NAME}-test ${TARGET_NAME})
|
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES
|
|
||||||
EXCLUDE_FROM_DEFAULT_BUILD TRUE
|
|
||||||
EXCLUDE_FROM_ALL TRUE)
|
|
||||||
|
|
||||||
list (APPEND ${TEST_PROJ_NAME}_TARGETS ${TARGET_NAME})
|
|
||||||
#list (APPEND ALL_TEST_TARGETS ${TARGET_NAME})
|
|
||||||
|
|
||||||
set(${TARGET_NAME}_DEPENDENCY_QT_MODULES ${ARGN})
|
|
||||||
|
|
||||||
list(APPEND ${TARGET_NAME}_DEPENDENCY_QT_MODULES Core Test)
|
|
||||||
|
|
||||||
# find these Qt modules and link them to our own target
|
|
||||||
find_package(Qt5 COMPONENTS ${${TARGET_NAME}_DEPENDENCY_QT_MODULES} REQUIRED)
|
|
||||||
|
|
||||||
foreach(QT_MODULE ${${TARGET_NAME}_DEPENDENCY_QT_MODULES})
|
|
||||||
target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "hidden/test-executables")
|
|
||||||
|
|
||||||
# handle testcase-specific dependencies (this a macro that should be defined in the cmakelists.txt file in each tests subdir)
|
|
||||||
|
|
||||||
SETUP_TESTCASE_DEPENDENCIES ()
|
|
||||||
endforeach ()
|
|
||||||
|
|
||||||
set(TEST_TARGET ${TEST_PROJ_NAME}-tests)
|
|
||||||
|
|
||||||
# Add a dummy target so that the project files are visible.
|
|
||||||
# This target will also build + run the other test targets using ctest when built.
|
|
||||||
|
|
||||||
add_custom_target(${TEST_TARGET}
|
|
||||||
COMMAND ctest .
|
|
||||||
SOURCES ${TEST_PROJ_SRC_FILES} # display source files under the testcase target
|
|
||||||
DEPENDS ${${TEST_PROJ_NAME}_TARGETS})
|
|
||||||
set_target_properties(${TEST_TARGET} PROPERTIES
|
|
||||||
EXCLUDE_FROM_DEFAULT_BUILD TRUE
|
|
||||||
EXCLUDE_FROM_ALL TRUE)
|
|
||||||
|
|
||||||
set_target_properties(${TEST_TARGET} PROPERTIES FOLDER "Tests")
|
|
||||||
|
|
||||||
list (APPEND ALL_TEST_TARGETS ${TEST_TARGET})
|
|
||||||
set(ALL_TEST_TARGETS "${ALL_TEST_TARGETS}" PARENT_SCOPE)
|
|
||||||
else ()
|
|
||||||
message(WARNING "No testcases in " ${TEST_PROJ_NAME})
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
endmacro(SETUP_HIFI_TESTCASE)
|
|
|
@ -6,16 +6,16 @@ enable_testing()
|
||||||
file(GLOB TEST_SUBDIRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*")
|
file(GLOB TEST_SUBDIRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*")
|
||||||
list(REMOVE_ITEM TEST_SUBDIRS "CMakeFiles")
|
list(REMOVE_ITEM TEST_SUBDIRS "CMakeFiles")
|
||||||
foreach(DIR ${TEST_SUBDIRS})
|
foreach(DIR ${TEST_SUBDIRS})
|
||||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}")
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}")
|
||||||
set(TEST_PROJ_NAME ${DIR})
|
set(TEST_PROJ_NAME ${DIR})
|
||||||
add_subdirectory(${DIR}) # link in the subdir (this reinvokes cmake on the cmakelists.txt file, with its
|
add_subdirectory(${DIR})
|
||||||
endif() # own variable scope copied from this scope (the parent scope)).
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
file(GLOB SHARED_TEST_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
|
file(GLOB SHARED_TEST_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
|
||||||
|
|
||||||
add_custom_target("test-extensions"
|
add_custom_target("test-extensions"
|
||||||
SOURCES "${SHARED_TEST_HEADER_FILES}")
|
SOURCES "${SHARED_TEST_HEADER_FILES}")
|
||||||
list(APPEND ALL_TEST_TARGETS "test-extensions")
|
list(APPEND ALL_TEST_TARGETS "test-extensions")
|
||||||
set_target_properties("test-extensions" PROPERTIES FOLDER "Tests")
|
set_target_properties("test-extensions" PROPERTIES FOLDER "Tests")
|
||||||
|
|
||||||
|
@ -23,20 +23,15 @@ message(STATUS "ALL_TEST_TARGETS = ${ALL_TEST_TARGETS}")
|
||||||
|
|
||||||
# Create the all-tests build target.
|
# Create the all-tests build target.
|
||||||
# The dependency list (ALL_TEST_TARGETS) is generated from setup_hifi_testcase invocations in the CMakeLists.txt
|
# The dependency list (ALL_TEST_TARGETS) is generated from setup_hifi_testcase invocations in the CMakeLists.txt
|
||||||
# files in the test subdirs. Since variables normally do *not* persist into parent scope, we use a hack:
|
# files in the test subdirs. Note: since variables normally do *not* persist into parent scope, we use a hack:
|
||||||
#
|
#
|
||||||
# list(APPEND ALL_TEST_TARGETS ${targets_to_add...}) # appends to a local list var (copied from parent scope)
|
# list(APPEND ALL_TEST_TARGETS ${targets_to_add...}) # appends to a local list var (copied from parent scope)
|
||||||
# set (ALL_TEST_TARGETS "${ALL_TEST_TARGETS}" PARENT_SCOPE) # copies this back to parent scope
|
# set (ALL_TEST_TARGETS "${ALL_TEST_TARGETS}" PARENT_SCOPE) # copies this back to parent scope
|
||||||
#
|
#
|
||||||
add_custom_target("all-tests"
|
add_custom_target("all-tests"
|
||||||
COMMAND ctest .
|
COMMAND ctest .
|
||||||
DEPENDS "${ALL_TEST_TARGETS}")
|
DEPENDS "${ALL_TEST_TARGETS}")
|
||||||
set_target_properties("all-tests" PROPERTIES FOLDER "hidden/test-targets")
|
set_target_properties("all-tests" PROPERTIES FOLDER "hidden/test-targets")
|
||||||
set_target_properties("all-tests" PROPERTIES
|
set_target_properties("all-tests" PROPERTIES
|
||||||
EXCLUDE_FROM_DEFAULT_BUILD TRUE
|
EXCLUDE_FROM_DEFAULT_BUILD TRUE
|
||||||
EXCLUDE_FROM_ALL TRUE)
|
EXCLUDE_FROM_ALL TRUE)
|
||||||
|
|
||||||
|
|
||||||
# Note: we also do some funky stuff with macros (SETUP_TESTCASE_DEPENDENCIES is redefined in *each* CMakeLists.txt
|
|
||||||
# file, and then invoked in SetupHifiTestCase.cmake) -- which is necessary since the dependencies must be re-linked
|
|
||||||
# for each target (instead of just one)
|
|
|
@ -47,12 +47,12 @@
|
||||||
// Additional messages (after actual/expected) can be written using the std::function callback.
|
// Additional messages (after actual/expected) can be written using the std::function callback.
|
||||||
// If these messages span more than one line, wrap them with "\n\t" to get proper indentation / formatting)
|
// If these messages span more than one line, wrap them with "\n\t" to get proper indentation / formatting)
|
||||||
//
|
//
|
||||||
template <typename T>
|
template <typename T> inline
|
||||||
inline QString QTest_generateCompareFailureMessage (
|
QString QTest_generateCompareFailureMessage (
|
||||||
const char * failMessage,
|
const char* failMessage,
|
||||||
const T & actual, const T & expected,
|
const T& actual, const T& expected,
|
||||||
const char * actual_expr, const char * expected_expr,
|
const char* actual_expr, const char* expected_expr,
|
||||||
std::function<QTextStream & (QTextStream &)> writeAdditionalMessages
|
std::function<QTextStream& (QTextStream&)> writeAdditionalMessages
|
||||||
) {
|
) {
|
||||||
QString s1 = actual_expr, s2 = expected_expr;
|
QString s1 = actual_expr, s2 = expected_expr;
|
||||||
int pad1_ = qMax(s2.length() - s1.length(), 0);
|
int pad1_ = qMax(s2.length() - s1.length(), 0);
|
||||||
|
@ -79,11 +79,11 @@ inline QString QTest_generateCompareFailureMessage (
|
||||||
// Loc: [<file path....>(<linenum>)]
|
// Loc: [<file path....>(<linenum>)]
|
||||||
// (no message callback)
|
// (no message callback)
|
||||||
//
|
//
|
||||||
template <typename T>
|
template <typename T> inline
|
||||||
inline QString QTest_generateCompareFailureMessage (
|
QString QTest_generateCompareFailureMessage (
|
||||||
const char * failMessage,
|
const char* failMessage,
|
||||||
const T & actual, const T & expected,
|
const T& actual, const T& expected,
|
||||||
const char * actual_expr, const char * expected_expr
|
const char* actual_expr, const char* expected_expr
|
||||||
) {
|
) {
|
||||||
QString s1 = actual_expr, s2 = expected_expr;
|
QString s1 = actual_expr, s2 = expected_expr;
|
||||||
int pad1_ = qMax(s2.length() - s1.length(), 0);
|
int pad1_ = qMax(s2.length() - s1.length(), 0);
|
||||||
|
@ -102,15 +102,17 @@ inline QString QTest_generateCompareFailureMessage (
|
||||||
|
|
||||||
// Hacky function that can assemble a QString from a QTextStream via a callback
|
// Hacky function that can assemble a QString from a QTextStream via a callback
|
||||||
// (ie. stream operations w/out qDebug())
|
// (ie. stream operations w/out qDebug())
|
||||||
inline QString makeMessageFromStream (std::function<void(QTextStream &)> writeMessage) {
|
inline
|
||||||
|
QString makeMessageFromStream (std::function<void(QTextStream&)> writeMessage) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QTextStream stream(&msg);
|
QTextStream stream(&msg);
|
||||||
writeMessage(stream);
|
writeMessage(stream);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QTest_failWithCustomMessage (
|
inline
|
||||||
std::function<void(QTextStream &stream)> writeMessage, int line, const char *file
|
void QTest_failWithCustomMessage (
|
||||||
|
std::function<void(QTextStream&)> writeMessage, int line, const char* file
|
||||||
) {
|
) {
|
||||||
QTest::qFail(qPrintable(makeMessageFromStream(writeMessage)), file, line);
|
QTest::qFail(qPrintable(makeMessageFromStream(writeMessage)), file, line);
|
||||||
}
|
}
|
||||||
|
@ -133,38 +135,44 @@ do { \
|
||||||
|
|
||||||
// Calls qFail using QTest_generateCompareFailureMessage.
|
// Calls qFail using QTest_generateCompareFailureMessage.
|
||||||
// This is (usually) wrapped in macros, but if you call this directly you should return immediately to get QFAIL semantics.
|
// This is (usually) wrapped in macros, but if you call this directly you should return immediately to get QFAIL semantics.
|
||||||
template <typename T>
|
template <typename T> inline
|
||||||
inline void QTest_failWithMessage(
|
void QTest_failWithMessage(
|
||||||
const char * failMessage,
|
const char* failMessage,
|
||||||
const T & actual, const T & expected,
|
const T& actual, const T& expected,
|
||||||
const char * actualExpr, const char * expectedExpr,
|
const char* actualExpr, const char* expectedExpr,
|
||||||
int line, const char * file
|
int line, const char* file
|
||||||
) {
|
) {
|
||||||
QTest::qFail(qPrintable(QTest_generateCompareFailureMessage(failMessage, actual, expected, actualExpr, expectedExpr)), file, line);
|
QTest::qFail(qPrintable(QTest_generateCompareFailureMessage(
|
||||||
|
failMessage, actual, expected, actualExpr, expectedExpr)), file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calls qFail using QTest_generateCompareFailureMessage.
|
// Calls qFail using QTest_generateCompareFailureMessage.
|
||||||
// This is (usually) wrapped in macros, but if you call this directly you should return immediately to get QFAIL semantics.
|
// This is (usually) wrapped in macros, but if you call this directly you should return immediately to get QFAIL semantics.
|
||||||
template <typename T>
|
template <typename T> inline
|
||||||
inline void QTest_failWithMessage(
|
void QTest_failWithMessage(
|
||||||
const char * failMessage,
|
const char* failMessage,
|
||||||
const T & actual, const T & expected,
|
const T& actual, const T& expected,
|
||||||
const char * actualExpr, const char * expectedExpr,
|
const char* actualExpr, const char* expectedExpr,
|
||||||
int line, const char * file,
|
int line, const char* file,
|
||||||
std::function<QTextStream &(QTextStream&)> writeAdditionalMessageLines
|
std::function<QTextStream& (QTextStream&)> writeAdditionalMessageLines
|
||||||
) {
|
) {
|
||||||
QTest::qFail(qPrintable(QTest_generateCompareFailureMessage(failMessage, actual, expected, actualExpr, expectedExpr, writeAdditionalMessageLines)), file, line);
|
QTest::qFail(qPrintable(QTest_generateCompareFailureMessage(
|
||||||
|
failMessage, actual, expected, actualExpr, expectedExpr, writeAdditionalMessageLines)), file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements QCOMPARE_WITH_ABS_ERROR
|
// Implements QCOMPARE_WITH_ABS_ERROR
|
||||||
template <typename T, typename V>
|
template <typename T, typename V> inline
|
||||||
inline bool QTest_compareWithAbsError(const T & actual, const T & expected, const char * actual_expr, const char * expected_expr, int line, const char * file, const V & epsilon)
|
bool QTest_compareWithAbsError(
|
||||||
{
|
const T& actual, const T& expected,
|
||||||
|
const char* actual_expr, const char* expected_expr,
|
||||||
|
int line, const char* file,
|
||||||
|
const V& epsilon
|
||||||
|
) {
|
||||||
if (abs(getErrorDifference(actual, expected)) > abs(epsilon)) {
|
if (abs(getErrorDifference(actual, expected)) > abs(epsilon)) {
|
||||||
QTest_failWithMessage(
|
QTest_failWithMessage(
|
||||||
"Compared values are not the same (fuzzy compare)",
|
"Compared values are not the same (fuzzy compare)",
|
||||||
actual, expected, actual_expr, expected_expr, line, file,
|
actual, expected, actual_expr, expected_expr, line, file,
|
||||||
[&] (QTextStream & stream) -> QTextStream & {
|
[&] (QTextStream& stream) -> QTextStream& {
|
||||||
return stream << "Err tolerance: " << getErrorDifference((actual), (expected)) << " > " << epsilon;
|
return stream << "Err tolerance: " << getErrorDifference((actual), (expected)) << " > " << epsilon;
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
|
@ -187,7 +195,7 @@ inline bool QTest_compareWithAbsError(const T & actual, const T & expected, cons
|
||||||
//
|
//
|
||||||
#define QCOMPARE_WITH_ABS_ERROR(actual, expected, epsilon) \
|
#define QCOMPARE_WITH_ABS_ERROR(actual, expected, epsilon) \
|
||||||
do { \
|
do { \
|
||||||
if (!QTest_compareWithAbsError(actual, expected, #actual, #expected, __LINE__, __FILE__, epsilon)) \
|
if (!QTest_compareWithAbsError((actual), (expected), #actual, #expected, __LINE__, __FILE__, epsilon)) \
|
||||||
return; \
|
return; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
@ -199,8 +207,8 @@ do { \
|
||||||
//
|
//
|
||||||
#define QCOMPARE_WITH_FUNCTION(actual, expected, testFunc) \
|
#define QCOMPARE_WITH_FUNCTION(actual, expected, testFunc) \
|
||||||
do { \
|
do { \
|
||||||
if (!testFunc(actual, expected)) { \
|
if (!(testFunc((actual), (expected)))) { \
|
||||||
QTest_failWithMessage("Compared values are not the same", actual, expected, #actual, #expected, __LINE__, __FILE__); \
|
QTest_failWithMessage("Compared values are not the same", (actual), (expected), #actual, #expected, __LINE__, __FILE__); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -217,8 +225,8 @@ do { \
|
||||||
//
|
//
|
||||||
#define QCOMPARE_WITH_LAMBDA(actual, expected, testClosure) \
|
#define QCOMPARE_WITH_LAMBDA(actual, expected, testClosure) \
|
||||||
do { \
|
do { \
|
||||||
if (!testClosure()) { \
|
if (!(testClosure())) { \
|
||||||
QTest_failWithMessage("Compared values are not the same", actual, expected, #actual, #expected, __LINE__, __FILE__); \
|
QTest_failWithMessage("Compared values are not the same", (actual), (expected), #actual, #expected, __LINE__, __FILE__); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -226,8 +234,8 @@ do { \
|
||||||
// Same as QCOMPARE_WITH_FUNCTION, but with a custom fail message
|
// Same as QCOMPARE_WITH_FUNCTION, but with a custom fail message
|
||||||
#define QCOMPARE_WITH_FUNCTION_AND_MESSAGE(actual, expected, testfunc, failMessage) \
|
#define QCOMPARE_WITH_FUNCTION_AND_MESSAGE(actual, expected, testfunc, failMessage) \
|
||||||
do { \
|
do { \
|
||||||
if (!testFunc(actual, expected)) { \
|
if (!(testFunc((actual), (expected)))) { \
|
||||||
QTest_failWithMessage(failMessage, actual, expected, #actual, #expected, __LINE__, __FILE__); \
|
QTest_failWithMessage((failMessage), (actual), (expected), #actual, #expected, __LINE__, __FILE__); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -235,8 +243,8 @@ do { \
|
||||||
// Same as QCOMPARE_WITH_FUNCTION, but with a custom fail message
|
// Same as QCOMPARE_WITH_FUNCTION, but with a custom fail message
|
||||||
#define QCOMPARE_WITH_LAMBDA_AND_MESSAGE(actual, expected, testClosure, failMessage) \
|
#define QCOMPARE_WITH_LAMBDA_AND_MESSAGE(actual, expected, testClosure, failMessage) \
|
||||||
do { \
|
do { \
|
||||||
if (!testClosure()) { \
|
if (!(testClosure())) { \
|
||||||
QTest_failWithMessage(failMessage, actual, expected, #actual, #expected, __LINE__, __FILE__); \
|
QTest_failWithMessage((failMessage), (actual), (expected), #actual, #expected, __LINE__, __FILE__); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# Declare dependencies
|
# Declare dependencies
|
||||||
macro (SETUP_TESTCASE_DEPENDENCIES)
|
macro (SETUP_TESTCASE_DEPENDENCIES)
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
link_hifi_libraries(shared audio networking)
|
link_hifi_libraries(shared audio networking)
|
||||||
|
|
||||||
copy_dlls_beside_windows_executable()
|
copy_dlls_beside_windows_executable()
|
||||||
endmacro ()
|
endmacro ()
|
||||||
|
|
||||||
setup_hifi_testcase()
|
setup_hifi_testcase()
|
|
@ -1,4 +1,4 @@
|
||||||
//
|
//
|
||||||
// AudioRingBufferTests.cpp
|
// AudioRingBufferTests.cpp
|
||||||
// tests/audio/src
|
// tests/audio/src
|
||||||
//
|
//
|
||||||
|
@ -124,6 +124,4 @@ void AudioRingBufferTests::runAllTests() {
|
||||||
}
|
}
|
||||||
assertBufferSize(ringBuffer, 0);
|
assertBufferSize(ringBuffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// qDebug() << "PASSED";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
# Declare dependencies
|
# Declare dependencies
|
||||||
macro (setup_testcase_dependencies)
|
macro (setup_testcase_dependencies)
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
link_hifi_libraries(shared networking)
|
link_hifi_libraries(shared networking)
|
||||||
|
|
||||||
copy_dlls_beside_windows_executable()
|
copy_dlls_beside_windows_executable()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
setup_hifi_testcase()
|
setup_hifi_testcase()
|
|
@ -1,9 +1,11 @@
|
||||||
//
|
//
|
||||||
// JitterTests.h
|
// QTestExtensions.h
|
||||||
// hifi
|
// tests/jitter/src
|
||||||
//
|
//
|
||||||
// Created by Seiji Emery on 6/23/15.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef hifi_JitterTests_h
|
#ifndef hifi_JitterTests_h
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
# Declare dependencies
|
# Declare dependencies
|
||||||
macro (setup_testcase_dependencies)
|
macro (setup_testcase_dependencies)
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
link_hifi_libraries(shared networking)
|
link_hifi_libraries(shared networking)
|
||||||
|
|
||||||
copy_dlls_beside_windows_executable()
|
copy_dlls_beside_windows_executable()
|
||||||
endmacro ()
|
endmacro ()
|
||||||
|
|
||||||
setup_hifi_testcase()
|
setup_hifi_testcase()
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// AudioRingBufferTests.cpp
|
// SequenceNumberStatsTests.cpp
|
||||||
// tests/networking/src
|
// tests/networking/src
|
||||||
//
|
//
|
||||||
// Created by Yixin Wang on 6/24/2014
|
// Created by Yixin Wang on 6/24/2014
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// AudioRingBufferTests.h
|
// SequenceNumberStatsTests.h
|
||||||
// tests/networking/src
|
// tests/networking/src
|
||||||
//
|
//
|
||||||
// Created by Yixin Wang on 6/24/2014
|
// Created by Yixin Wang on 6/24/2014
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
# Declare dependencies
|
# Declare dependencies
|
||||||
macro (setup_testcase_dependencies)
|
macro (setup_testcase_dependencies)
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
link_hifi_libraries(shared octree gpu model fbx networking environment entities avatars audio animation script-engine physics)
|
link_hifi_libraries(shared octree gpu model fbx networking environment entities avatars audio animation script-engine physics)
|
||||||
|
|
||||||
copy_dlls_beside_windows_executable()
|
copy_dlls_beside_windows_executable()
|
||||||
endmacro ()
|
endmacro ()
|
||||||
|
|
||||||
setup_hifi_testcase(Script Network)
|
setup_hifi_testcase(Script Network)
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
|
||||||
class AABoxCubeTests : public QObject {
|
class AABoxCubeTests : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,6 @@ void OctreeTests::propertyFlagsTests() {
|
||||||
// testsFailed++;
|
// testsFailed++;
|
||||||
// qDebug() << "FAILED - Test 3b: remove flag with -= EXAMPLE_PROP_PAUSE_SIMULATION";
|
// qDebug() << "FAILED - Test 3b: remove flag with -= EXAMPLE_PROP_PAUSE_SIMULATION";
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
|
|
||||||
# Declare dependencies
|
# Declare dependencies
|
||||||
macro (SETUP_TESTCASE_DEPENDENCIES)
|
macro (SETUP_TESTCASE_DEPENDENCIES)
|
||||||
add_dependency_external_projects(glm)
|
add_dependency_external_projects(glm)
|
||||||
find_package(GLM REQUIRED)
|
find_package(GLM REQUIRED)
|
||||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||||
|
|
||||||
add_dependency_external_projects(bullet)
|
add_dependency_external_projects(bullet)
|
||||||
|
|
||||||
find_package(Bullet REQUIRED)
|
find_package(Bullet REQUIRED)
|
||||||
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS})
|
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS})
|
||||||
target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES})
|
target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES})
|
||||||
|
|
||||||
link_hifi_libraries(shared physics)
|
link_hifi_libraries(shared physics)
|
||||||
copy_dlls_beside_windows_executable()
|
copy_dlls_beside_windows_executable()
|
||||||
endmacro ()
|
endmacro ()
|
||||||
|
|
||||||
setup_hifi_testcase(Script)
|
setup_hifi_testcase(Script)
|
|
@ -23,19 +23,16 @@
|
||||||
// (used by QCOMPARE_WITH_RELATIVE_ERROR via QCOMPARE_WITH_LAMBDA)
|
// (used by QCOMPARE_WITH_RELATIVE_ERROR via QCOMPARE_WITH_LAMBDA)
|
||||||
// (this is only used by btMatrix3x3 in MeshMassPropertiesTests.cpp, so it's only defined for the Mat3 type)
|
// (this is only used by btMatrix3x3 in MeshMassPropertiesTests.cpp, so it's only defined for the Mat3 type)
|
||||||
|
|
||||||
//
|
// Return the error between values a and b; used to implement QCOMPARE_WITH_ABS_ERROR
|
||||||
// fuzzy compare (this is a distance function, basically)
|
inline btScalar getErrorDifference(const btScalar& a, const btScalar& b) {
|
||||||
//
|
|
||||||
|
|
||||||
inline btScalar getErrorDifference(const btScalar & a, const btScalar & b) {
|
|
||||||
return fabs(a - b);
|
return fabs(a - b);
|
||||||
}
|
}
|
||||||
inline btScalar getErrorDifference(const btVector3 & a, const btVector3 & b)
|
// Return the error between values a and b; used to implement QCOMPARE_WITH_ABS_ERROR
|
||||||
{
|
inline btScalar getErrorDifference(const btVector3& a, const btVector3& b) {
|
||||||
return (a - b).length();
|
return (a - b).length();
|
||||||
}
|
}
|
||||||
// Matrices are compared element-wise -- if the error value for any element > epsilon, then fail
|
// Matrices are compared element-wise -- if the error value for any element > epsilon, then fail
|
||||||
inline btScalar getErrorDifference (const btMatrix3x3 & a, const btMatrix3x3 & b) {
|
inline btScalar getErrorDifference (const btMatrix3x3& a, const btMatrix3x3& b) {
|
||||||
btScalar maxDiff = 0;
|
btScalar maxDiff = 0;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
for (int j = 0; j < 3; ++j) {
|
for (int j = 0; j < 3; ++j) {
|
||||||
|
@ -51,7 +48,7 @@ inline btScalar getErrorDifference (const btMatrix3x3 & a, const btMatrix3x3 & b
|
||||||
//
|
//
|
||||||
|
|
||||||
// btMatrix3x3 stream printing (not advised to use this outside of the test macros, due to formatting)
|
// btMatrix3x3 stream printing (not advised to use this outside of the test macros, due to formatting)
|
||||||
inline QTextStream & operator << (QTextStream & stream, const btMatrix3x3 & matrix) {
|
inline QTextStream& operator << (QTextStream& stream, const btMatrix3x3& matrix) {
|
||||||
stream << "[\n\t\t";
|
stream << "[\n\t\t";
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
for (int j = 0; j < 3; ++j) {
|
for (int j = 0; j < 3; ++j) {
|
||||||
|
@ -62,7 +59,7 @@ inline QTextStream & operator << (QTextStream & stream, const btMatrix3x3 & matr
|
||||||
stream << "]\n\t"; // hacky as hell, but this should work...
|
stream << "]\n\t"; // hacky as hell, but this should work...
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
inline QTextStream & operator << (QTextStream & stream, const btVector3 & v) {
|
inline QTextStream& operator << (QTextStream& stream, const btVector3& v) {
|
||||||
return stream << "btVector3 { " << v.x() << ", " << v.y() << ", " << v.z() << " }";
|
return stream << "btVector3 { " << v.x() << ", " << v.y() << ", " << v.z() << " }";
|
||||||
}
|
}
|
||||||
// btScalar operator<< is already implemented (as it's just a typedef-ed float/double)
|
// btScalar operator<< is already implemented (as it's just a typedef-ed float/double)
|
||||||
|
@ -71,8 +68,9 @@ inline QTextStream & operator << (QTextStream & stream, const btVector3 & v) {
|
||||||
// errorTest (actual, expected, acceptableRelativeError) -> callback closure
|
// errorTest (actual, expected, acceptableRelativeError) -> callback closure
|
||||||
//
|
//
|
||||||
|
|
||||||
// Produces a relative error test for btMatrix3x3 usable with QCOMPARE_WITH_LAMBDA
|
// Produces a relative error test for btMatrix3x3 usable with QCOMPARE_WITH_LAMBDA.
|
||||||
inline auto errorTest (const btMatrix3x3 & actual, const btMatrix3x3 & expected, const btScalar acceptableRelativeError)
|
// (used in a *few* physics tests that define QCOMPARE_WITH_RELATIVE_ERROR)
|
||||||
|
inline auto errorTest (const btMatrix3x3& actual, const btMatrix3x3& expected, const btScalar acceptableRelativeError)
|
||||||
-> std::function<bool ()>
|
-> std::function<bool ()>
|
||||||
{
|
{
|
||||||
return [&actual, &expected, acceptableRelativeError] () {
|
return [&actual, &expected, acceptableRelativeError] () {
|
||||||
|
@ -83,9 +81,11 @@ inline auto errorTest (const btMatrix3x3 & actual, const btMatrix3x3 & expected,
|
||||||
if (fabsf(err) > acceptableRelativeError)
|
if (fabsf(err) > acceptableRelativeError)
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// handle zero-case by also calling QCOMPARE_WITH_ABS_ERROR
|
// The zero-case (where expected[i][j] == 0) is covered by the QCOMPARE_WITH_ABS_ERROR impl
|
||||||
// (this function implements QCOMPARE_WITH_RELATIVE_ERROR, so call both
|
// (ie. getErrorDifference (const btMatrix3x3& a, const btMatrix3x3& b).
|
||||||
// to test matrices)
|
// Since the zero-case uses a different error value (abs error) vs the non-zero case (relative err),
|
||||||
|
// it made sense to separate these two cases. To do a full check, call QCOMPARE_WITH_RELATIVE_ERROR
|
||||||
|
// followed by QCOMPARE_WITH_ABS_ERROR (or vice versa).
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,12 +65,3 @@ void BulletUtilTests::fromGLMToBullet() {
|
||||||
QCOMPARE(gQ.z, bQ.getZ());
|
QCOMPARE(gQ.z, bQ.getZ());
|
||||||
QCOMPARE(gQ.w, bQ.getW());
|
QCOMPARE(gQ.w, bQ.getW());
|
||||||
}
|
}
|
||||||
|
|
||||||
//void BulletUtilTests::fooTest () {
|
|
||||||
//
|
|
||||||
// glm::vec3 a { 1, 0, 3 };
|
|
||||||
// glm::vec3 b { 2, 0, 5 };
|
|
||||||
//
|
|
||||||
//// QCOMPARE(10, 22);
|
|
||||||
// QCOMPARE_WITH_ABS_ERROR(a, b, 1.0f);
|
|
||||||
//}
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ class BulletUtilTests : public QObject {
|
||||||
private slots:
|
private slots:
|
||||||
void fromBulletToGLM();
|
void fromBulletToGLM();
|
||||||
void fromGLMToBullet();
|
void fromGLMToBullet();
|
||||||
// void fooTest ();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_BulletUtilTests_h
|
#endif // hifi_BulletUtilTests_h
|
||||||
|
|
|
@ -40,33 +40,12 @@ void CollisionInfoTests::rotateThenTranslate() {
|
||||||
|
|
||||||
collision.rotateThenTranslate(rotation, translation);
|
collision.rotateThenTranslate(rotation, translation);
|
||||||
QCOMPARE(collision._penetration, xYxis);
|
QCOMPARE(collision._penetration, xYxis);
|
||||||
// float error = glm::distance(collision._penetration, xYxis);
|
|
||||||
// if (error > EPSILON) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: collision._penetration = " << collision._penetration
|
|
||||||
// << " but we expected " << xYxis
|
|
||||||
// << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
glm::vec3 expectedContactPoint = -xAxis + translation;
|
glm::vec3 expectedContactPoint = -xAxis + translation;
|
||||||
QCOMPARE(collision._contactPoint, expectedContactPoint);
|
QCOMPARE(collision._contactPoint, expectedContactPoint);
|
||||||
// error = glm::distance(collision._contactPoint, expectedContactPoint);
|
|
||||||
// if (error > EPSILON) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: collision._contactPoint = " << collision._contactPoint
|
|
||||||
// << " but we expected " << expectedContactPoint
|
|
||||||
// << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
glm::vec3 expectedAddedVelocity = xYxis - xAxis + xZxis;
|
glm::vec3 expectedAddedVelocity = xYxis - xAxis + xZxis;
|
||||||
QCOMPARE(collision._addedVelocity, expectedAddedVelocity);
|
QCOMPARE(collision._addedVelocity, expectedAddedVelocity);
|
||||||
// error = glm::distance(collision._addedVelocity, expectedAddedVelocity);
|
|
||||||
// if (error > EPSILON) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: collision._addedVelocity = " << collision._contactPoint
|
|
||||||
// << " but we expected " << expectedAddedVelocity
|
|
||||||
// << std::endl;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollisionInfoTests::translateThenRotate() {
|
void CollisionInfoTests::translateThenRotate() {
|
||||||
|
@ -81,32 +60,11 @@ void CollisionInfoTests::translateThenRotate() {
|
||||||
|
|
||||||
collision.translateThenRotate(translation, rotation);
|
collision.translateThenRotate(translation, rotation);
|
||||||
QCOMPARE(collision._penetration, -xYxis);
|
QCOMPARE(collision._penetration, -xYxis);
|
||||||
// float error = glm::distance(collision._penetration, -xYxis);
|
|
||||||
// if (error > EPSILON) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: collision._penetration = " << collision._penetration
|
|
||||||
// << " but we expected " << -yAxis
|
|
||||||
// << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
glm::vec3 expectedContactPoint = (1.0f + distance) * xAxis;
|
glm::vec3 expectedContactPoint = (1.0f + distance) * xAxis;
|
||||||
QCOMPARE(collision._contactPoint, expectedContactPoint);
|
QCOMPARE(collision._contactPoint, expectedContactPoint);
|
||||||
// error = glm::distance(collision._contactPoint, expectedContactPoint);
|
|
||||||
// if (error > EPSILON) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: collision._contactPoint = " << collision._contactPoint
|
|
||||||
// << " but we expected " << expectedContactPoint
|
|
||||||
// << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
glm::vec3 expectedAddedVelocity = - xYxis + xAxis + xYxis;
|
glm::vec3 expectedAddedVelocity = - xYxis + xAxis + xYxis;
|
||||||
QCOMPARE(collision._addedVelocity, expectedAddedVelocity);
|
QCOMPARE(collision._addedVelocity, expectedAddedVelocity);
|
||||||
// error = glm::distance(collision._addedVelocity, expectedAddedVelocity);
|
|
||||||
// if (error > EPSILON) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: collision._addedVelocity = " << collision._contactPoint
|
|
||||||
// << " but we expected " << expectedAddedVelocity
|
|
||||||
// << std::endl;
|
|
||||||
// }
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
|
@ -15,24 +15,11 @@
|
||||||
|
|
||||||
#include "MeshMassPropertiesTests.h"
|
#include "MeshMassPropertiesTests.h"
|
||||||
|
|
||||||
#define VERBOSE_UNIT_TESTS
|
|
||||||
|
|
||||||
const btScalar acceptableRelativeError(1.0e-5f);
|
const btScalar acceptableRelativeError(1.0e-5f);
|
||||||
const btScalar acceptableAbsoluteError(1.0e-4f);
|
const btScalar acceptableAbsoluteError(1.0e-4f);
|
||||||
|
|
||||||
QTEST_MAIN(MeshMassPropertiesTests)
|
QTEST_MAIN(MeshMassPropertiesTests)
|
||||||
|
|
||||||
void printMatrix(const std::string& name, const btMatrix3x3& matrix) {
|
|
||||||
std::cout << name << " = [" << std::endl;
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
for (int j = 0; j < 3; ++j) {
|
|
||||||
std::cout << " " << matrix[i][j];
|
|
||||||
}
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
|
||||||
std::cout << "]" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pushTriangle(VectorOfIndices& indices, uint32_t a, uint32_t b, uint32_t c) {
|
void pushTriangle(VectorOfIndices& indices, uint32_t a, uint32_t b, uint32_t c) {
|
||||||
indices.push_back(a);
|
indices.push_back(a);
|
||||||
indices.push_back(b);
|
indices.push_back(b);
|
||||||
|
@ -40,14 +27,10 @@ void pushTriangle(VectorOfIndices& indices, uint32_t a, uint32_t b, uint32_t c)
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshMassPropertiesTests::testParallelAxisTheorem() {
|
void MeshMassPropertiesTests::testParallelAxisTheorem() {
|
||||||
//#ifdef EXPOSE_HELPER_FUNCTIONS_FOR_UNIT_TEST
|
|
||||||
// verity we can compute the inertia tensor of a box in two different ways:
|
// verity we can compute the inertia tensor of a box in two different ways:
|
||||||
// (a) as one box
|
// (a) as one box
|
||||||
// (b) as a combination of two partial boxes.
|
// (b) as a combination of two partial boxes.
|
||||||
//#ifdef VERBOSE_UNIT_TESTS
|
|
||||||
// std::cout << "\n" << __FUNCTION__ << std::endl;
|
|
||||||
//#endif // VERBOSE_UNIT_TESTS
|
|
||||||
|
|
||||||
btScalar bigBoxX = 7.0f;
|
btScalar bigBoxX = 7.0f;
|
||||||
btScalar bigBoxY = 9.0f;
|
btScalar bigBoxY = 9.0f;
|
||||||
btScalar bigBoxZ = 11.0f;
|
btScalar bigBoxZ = 11.0f;
|
||||||
|
@ -90,12 +73,6 @@ void MeshMassPropertiesTests::testParallelAxisTheorem() {
|
||||||
|
|
||||||
// This now does the same as the above (using the maxDiff getErrorDifference impl for two btMatrices)
|
// This now does the same as the above (using the maxDiff getErrorDifference impl for two btMatrices)
|
||||||
QCOMPARE_WITH_ABS_ERROR(bitBoxInertia, twoSmallBoxesInertia, acceptableAbsoluteError);
|
QCOMPARE_WITH_ABS_ERROR(bitBoxInertia, twoSmallBoxesInertia, acceptableAbsoluteError);
|
||||||
|
|
||||||
//#ifdef VERBOSE_UNIT_TESTS
|
|
||||||
// printMatrix("expected inertia", bitBoxInertia);
|
|
||||||
// printMatrix("computed inertia", twoSmallBoxesInertia);
|
|
||||||
//#endif // VERBOSE_UNIT_TESTS
|
|
||||||
//#endif // EXPOSE_HELPER_FUNCTIONS_FOR_UNIT_TEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshMassPropertiesTests::testTetrahedron(){
|
void MeshMassPropertiesTests::testTetrahedron(){
|
||||||
|
@ -140,58 +117,14 @@ void MeshMassPropertiesTests::testTetrahedron(){
|
||||||
btMatrix3x3 inertia;
|
btMatrix3x3 inertia;
|
||||||
computeTetrahedronInertia(volume, points, inertia);
|
computeTetrahedronInertia(volume, points, inertia);
|
||||||
|
|
||||||
// if error = (volume - expectedVolume) / expectedVolume
|
|
||||||
// then fabsf(error) > acceptableRelativeError == fabsf(volume - expectedVolume) > err
|
|
||||||
// where err = acceptableRelativeError * expectedVolume
|
|
||||||
|
|
||||||
QCOMPARE_WITH_ABS_ERROR(volume, expectedVolume, acceptableRelativeError * volume);
|
QCOMPARE_WITH_ABS_ERROR(volume, expectedVolume, acceptableRelativeError * volume);
|
||||||
|
|
||||||
// pseudo-hack -- error value is calculated per-element, so QCOMPARE_WITH_ABS_ERROR will not work.
|
|
||||||
// QCOMPARE_WITH_FUNCTION and QCOMPARE_WITH_LAMBDA lets you get around this by writing
|
|
||||||
// a custom function to do the actual comparison; printing, etc is done automatically.
|
|
||||||
auto testFunc = [&inertia, &expectedInertia] () {
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
for (int j = 0; j < 3; ++j) {
|
|
||||||
auto error = (inertia[i][j] - expectedInertia[i][j]) / expectedInertia[i][j];
|
|
||||||
if (fabsf(error) > acceptableRelativeError)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
QCOMPARE_WITH_LAMBDA(inertia, expectedInertia, testFunc);
|
|
||||||
|
|
||||||
QCOMPARE_WITH_RELATIVE_ERROR(inertia, expectedInertia, acceptableRelativeError);
|
QCOMPARE_WITH_RELATIVE_ERROR(inertia, expectedInertia, acceptableRelativeError);
|
||||||
// // verify
|
|
||||||
// for (int i = 0; i < 3; ++i) {
|
|
||||||
// for (int j = 0; j < 3; ++j) {
|
|
||||||
// error = (inertia[i][j] - expectedInertia[i][j]) / expectedInertia[i][j];
|
|
||||||
// if (fabsf(error) > acceptableRelativeError) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : inertia[" << i << "][" << j << "] off by "
|
|
||||||
// << error << std::endl;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//#ifdef VERBOSE_UNIT_TESTS
|
|
||||||
// std::cout << "expected volume = " << expectedVolume << std::endl;
|
|
||||||
// std::cout << "measured volume = " << volume << std::endl;
|
|
||||||
// printMatrix("expected inertia", expectedInertia);
|
|
||||||
// printMatrix("computed inertia", inertia);
|
|
||||||
//
|
|
||||||
// // when building VERBOSE you might be instrested in the results from the brute force method:
|
|
||||||
// btMatrix3x3 bruteInertia;
|
|
||||||
// computeTetrahedronInertiaByBruteForce(points, bruteInertia);
|
|
||||||
// printMatrix("brute inertia", bruteInertia);
|
|
||||||
//#endif // VERBOSE_UNIT_TESTS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshMassPropertiesTests::testOpenTetrahedonMesh() {
|
void MeshMassPropertiesTests::testOpenTetrahedonMesh() {
|
||||||
// given the simplest possible mesh (open, with one triangle)
|
// given the simplest possible mesh (open, with one triangle)
|
||||||
// verify MeshMassProperties computes the right nubers
|
// verify MeshMassProperties computes the right nubers
|
||||||
//#ifdef VERBOSE_UNIT_TESTS
|
|
||||||
// std::cout << "\n" << __FUNCTION__ << std::endl;
|
|
||||||
//#endif // VERBOSE_UNIT_TESTS
|
|
||||||
|
|
||||||
// these numbers from the Tonon paper:
|
// these numbers from the Tonon paper:
|
||||||
VectorOfPoints points;
|
VectorOfPoints points;
|
||||||
|
@ -229,51 +162,14 @@ void MeshMassPropertiesTests::testOpenTetrahedonMesh() {
|
||||||
// verify
|
// verify
|
||||||
// (expected - actual) / expected > e ==> expected - actual > e * expected
|
// (expected - actual) / expected > e ==> expected - actual > e * expected
|
||||||
QCOMPARE_WITH_ABS_ERROR(mesh._volume, expectedVolume, acceptableRelativeError * expectedVolume);
|
QCOMPARE_WITH_ABS_ERROR(mesh._volume, expectedVolume, acceptableRelativeError * expectedVolume);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// btScalar error = (mesh._volume - expectedVolume) / expectedVolume;
|
|
||||||
// if (fabsf(error) > acceptableRelativeError) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : volume of tetrahedron off by = "
|
|
||||||
// << error << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
QCOMPARE_WITH_ABS_ERROR(mesh._centerOfMass, expectedCenterOfMass, acceptableAbsoluteError);
|
QCOMPARE_WITH_ABS_ERROR(mesh._centerOfMass, expectedCenterOfMass, acceptableAbsoluteError);
|
||||||
|
|
||||||
// error = (mesh._centerOfMass - expectedCenterOfMass).length();
|
|
||||||
// if (fabsf(error) > acceptableAbsoluteError) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : centerOfMass of tetrahedron off by = "
|
|
||||||
// << error << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
QCOMPARE_WITH_RELATIVE_ERROR(mesh._inertia, expectedInertia, acceptableRelativeError);
|
QCOMPARE_WITH_RELATIVE_ERROR(mesh._inertia, expectedInertia, acceptableRelativeError);
|
||||||
|
|
||||||
// for (int i = 0; i < 3; ++i) {
|
|
||||||
// for (int j = 0; j < 3; ++j) {
|
|
||||||
// error = (mesh._inertia[i][j] - expectedInertia[i][j]) / expectedInertia[i][j];
|
|
||||||
// if (fabsf(error) > acceptableRelativeError) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : inertia[" << i << "][" << j << "] off by "
|
|
||||||
// << error << std::endl;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//#ifdef VERBOSE_UNIT_TESTS
|
|
||||||
// std::cout << "expected volume = " << expectedVolume << std::endl;
|
|
||||||
// std::cout << "measured volume = " << mesh._volume << std::endl;
|
|
||||||
// printMatrix("expected inertia", expectedInertia);
|
|
||||||
// printMatrix("computed inertia", mesh._inertia);
|
|
||||||
//#endif // VERBOSE_UNIT_TESTS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshMassPropertiesTests::testClosedTetrahedronMesh() {
|
void MeshMassPropertiesTests::testClosedTetrahedronMesh() {
|
||||||
// given a tetrahedron as a closed mesh of four tiangles
|
// given a tetrahedron as a closed mesh of four tiangles
|
||||||
// verify MeshMassProperties computes the right nubers
|
// verify MeshMassProperties computes the right nubers
|
||||||
#ifdef VERBOSE_UNIT_TESTS
|
|
||||||
std::cout << "\n" << __FUNCTION__ << std::endl;
|
|
||||||
#endif // VERBOSE_UNIT_TESTS
|
|
||||||
|
|
||||||
// these numbers from the Tonon paper:
|
// these numbers from the Tonon paper:
|
||||||
VectorOfPoints points;
|
VectorOfPoints points;
|
||||||
points.push_back(btVector3(8.33220f, -11.86875f, 0.93355f));
|
points.push_back(btVector3(8.33220f, -11.86875f, 0.93355f));
|
||||||
|
@ -307,39 +203,8 @@ void MeshMassPropertiesTests::testClosedTetrahedronMesh() {
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
QCOMPARE_WITH_ABS_ERROR(mesh._volume, expectedVolume, acceptableRelativeError * expectedVolume);
|
QCOMPARE_WITH_ABS_ERROR(mesh._volume, expectedVolume, acceptableRelativeError * expectedVolume);
|
||||||
// btScalar error;
|
|
||||||
// error = (mesh._volume - expectedVolume) / expectedVolume;
|
|
||||||
// if (fabsf(error) > acceptableRelativeError) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : volume of tetrahedron off by = "
|
|
||||||
// << error << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
QCOMPARE_WITH_ABS_ERROR(mesh._centerOfMass, expectedCenterOfMass, acceptableAbsoluteError);
|
QCOMPARE_WITH_ABS_ERROR(mesh._centerOfMass, expectedCenterOfMass, acceptableAbsoluteError);
|
||||||
// error = (mesh._centerOfMass - expectedCenterOfMass).length();
|
|
||||||
// if (fabsf(error) > acceptableAbsoluteError) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : centerOfMass of tetrahedron off by = "
|
|
||||||
// << error << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
QCOMPARE_WITH_RELATIVE_ERROR(mesh._inertia, expectedInertia, acceptableRelativeError);
|
QCOMPARE_WITH_RELATIVE_ERROR(mesh._inertia, expectedInertia, acceptableRelativeError);
|
||||||
// for (int i = 0; i < 3; ++i) {
|
|
||||||
// for (int j = 0; j < 3; ++j) {
|
|
||||||
// error = (mesh._inertia[i][j] - expectedInertia[i][j]) / expectedInertia[i][j];
|
|
||||||
// if (fabsf(error) > acceptableRelativeError) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : inertia[" << i << "][" << j << "] off by "
|
|
||||||
// << error << std::endl;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//#ifdef VERBOSE_UNIT_TESTS
|
|
||||||
// std::cout << "(a) tetrahedron as mesh" << std::endl;
|
|
||||||
// std::cout << "expected volume = " << expectedVolume << std::endl;
|
|
||||||
// std::cout << "measured volume = " << mesh._volume << std::endl;
|
|
||||||
// printMatrix("expected inertia", expectedInertia);
|
|
||||||
// printMatrix("computed inertia", mesh._inertia);
|
|
||||||
//#endif // VERBOSE_UNIT_TESTS
|
|
||||||
|
|
||||||
// test again, but this time shift the points so that the origin is definitely OUTSIDE the mesh
|
// test again, but this time shift the points so that the origin is definitely OUTSIDE the mesh
|
||||||
btVector3 shift = points[0] + expectedCenterOfMass;
|
btVector3 shift = points[0] + expectedCenterOfMass;
|
||||||
|
@ -353,37 +218,8 @@ void MeshMassPropertiesTests::testClosedTetrahedronMesh() {
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
// QCOMPARE_WITH_ABS_ERROR(mesh._volume, expectedVolume, acceptableRelativeError * expectedVolume);
|
// QCOMPARE_WITH_ABS_ERROR(mesh._volume, expectedVolume, acceptableRelativeError * expectedVolume);
|
||||||
//// error = (mesh._volume - expectedVolume) / expectedVolume;
|
|
||||||
//// if (fabsf(error) > acceptableRelativeError) {
|
|
||||||
//// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : volume of tetrahedron off by = "
|
|
||||||
//// << error << std::endl;
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// QCOMPARE_WITH_ABS_ERROR(mesh._centerOfMass, expectedCenterOfMass, acceptableAbsoluteError);
|
// QCOMPARE_WITH_ABS_ERROR(mesh._centerOfMass, expectedCenterOfMass, acceptableAbsoluteError);
|
||||||
//// error = (mesh._centerOfMass - expectedCenterOfMass).length();
|
|
||||||
//// if (fabsf(error) > acceptableAbsoluteError) {
|
|
||||||
//// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : centerOfMass of tetrahedron off by = "
|
|
||||||
//// << error << std::endl;
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// QCOMPARE_WITH_RELATIVE_ERROR(mesh._inertia, expectedInertia, acceptableRelativeError);
|
// QCOMPARE_WITH_RELATIVE_ERROR(mesh._inertia, expectedInertia, acceptableRelativeError);
|
||||||
//// for (int i = 0; i < 3; ++i) {
|
|
||||||
//// for (int j = 0; j < 3; ++j) {
|
|
||||||
//// error = (mesh._inertia[i][j] - expectedInertia[i][j]) / expectedInertia[i][j];
|
|
||||||
//// if (fabsf(error) > acceptableRelativeError) {
|
|
||||||
//// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : inertia[" << i << "][" << j << "] off by "
|
|
||||||
//// << error << std::endl;
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
|
|
||||||
//#ifdef VERBOSE_UNIT_TESTS
|
|
||||||
// std::cout << "(b) shifted tetrahedron as mesh" << std::endl;
|
|
||||||
// std::cout << "expected volume = " << expectedVolume << std::endl;
|
|
||||||
// std::cout << "measured volume = " << mesh._volume << std::endl;
|
|
||||||
// printMatrix("expected inertia", expectedInertia);
|
|
||||||
// printMatrix("computed inertia", mesh._inertia);
|
|
||||||
//#endif // VERBOSE_UNIT_TESTS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshMassPropertiesTests::testBoxAsMesh() {
|
void MeshMassPropertiesTests::testBoxAsMesh() {
|
||||||
|
@ -445,25 +281,13 @@ void MeshMassPropertiesTests::testBoxAsMesh() {
|
||||||
// verify
|
// verify
|
||||||
|
|
||||||
QCOMPARE_WITH_ABS_ERROR(mesh._volume, expectedVolume, acceptableRelativeError * expectedVolume);
|
QCOMPARE_WITH_ABS_ERROR(mesh._volume, expectedVolume, acceptableRelativeError * expectedVolume);
|
||||||
// btScalar error;
|
|
||||||
// error = (mesh._volume - expectedVolume) / expectedVolume;
|
|
||||||
// if (fabsf(error) > acceptableRelativeError) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : volume of tetrahedron off by = "
|
|
||||||
// << error << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
QCOMPARE_WITH_ABS_ERROR(mesh._centerOfMass, expectedCenterOfMass, acceptableAbsoluteError);
|
QCOMPARE_WITH_ABS_ERROR(mesh._centerOfMass, expectedCenterOfMass, acceptableAbsoluteError);
|
||||||
// error = (mesh._centerOfMass - expectedCenterOfMass).length();
|
|
||||||
// if (fabsf(error) > acceptableAbsoluteError) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR : centerOfMass of tetrahedron off by = "
|
|
||||||
// << error << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
// test this twice: _RELATIVE_ERROR doesn't test zero cases (to avoid divide-by-zero); _ABS_ERROR does.
|
||||||
// do this twice to avoid divide-by-zero?
|
|
||||||
QCOMPARE_WITH_ABS_ERROR(mesh._inertia, expectedInertia, acceptableAbsoluteError);
|
QCOMPARE_WITH_ABS_ERROR(mesh._inertia, expectedInertia, acceptableAbsoluteError);
|
||||||
QCOMPARE_WITH_RELATIVE_ERROR(mesh._inertia, expectedInertia, acceptableRelativeError);
|
QCOMPARE_WITH_RELATIVE_ERROR(mesh._inertia, expectedInertia, acceptableRelativeError);
|
||||||
// float error;
|
|
||||||
|
// These two macros impl this:
|
||||||
// for (int i = 0; i < 3; ++i) {
|
// for (int i = 0; i < 3; ++i) {
|
||||||
// for (int j = 0; j < 3; ++j) {
|
// for (int j = 0; j < 3; ++j) {
|
||||||
// if (expectedInertia [i][j] == btScalar(0.0f)) {
|
// if (expectedInertia [i][j] == btScalar(0.0f)) {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -150,23 +150,11 @@ void ShapeInfoTests::testBoxShape() {
|
||||||
|
|
||||||
btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
||||||
QCOMPARE(shape != nullptr, true);
|
QCOMPARE(shape != nullptr, true);
|
||||||
// if (!shape) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: NULL Box shape" << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
DoubleHashKey otherKey = otherInfo.getHash();
|
DoubleHashKey otherKey = otherInfo.getHash();
|
||||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
QCOMPARE(key.getHash(), otherKey.getHash());
|
||||||
// if (key.getHash() != otherKey.getHash()) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected Box shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
||||||
// if (key.getHash2() != otherKey.getHash2()) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected Box shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
delete shape;
|
delete shape;
|
||||||
}
|
}
|
||||||
|
@ -183,15 +171,7 @@ void ShapeInfoTests::testSphereShape() {
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
DoubleHashKey otherKey = otherInfo.getHash();
|
DoubleHashKey otherKey = otherInfo.getHash();
|
||||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
QCOMPARE(key.getHash(), otherKey.getHash());
|
||||||
// if (key.getHash() != otherKey.getHash()) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected Sphere shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
|
||||||
// }
|
|
||||||
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
||||||
// if (key.getHash2() != otherKey.getHash2()) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected Sphere shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
delete shape;
|
delete shape;
|
||||||
}
|
}
|
||||||
|
@ -210,15 +190,7 @@ void ShapeInfoTests::testCylinderShape() {
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
DoubleHashKey otherKey = otherInfo.getHash();
|
DoubleHashKey otherKey = otherInfo.getHash();
|
||||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
QCOMPARE(key.getHash(), otherKey.getHash());
|
||||||
// if (key.getHash() != otherKey.getHash()) {
|
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected Cylinder shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
|
||||||
// }
|
|
||||||
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
|
||||||
// if (key.getHash2() != otherKey.getHash2()) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected Cylinder shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
delete shape;
|
delete shape;
|
||||||
*/
|
*/
|
||||||
|
@ -238,27 +210,9 @@ void ShapeInfoTests::testCapsuleShape() {
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
DoubleHashKey otherKey = otherInfo.getHash();
|
DoubleHashKey otherKey = otherInfo.getHash();
|
||||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
QCOMPARE(key.getHash(), otherKey.getHash());
|
||||||
// if (key.getHash() != otherKey.getHash()) {
|
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected Capsule shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
|
||||||
// }
|
|
||||||
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
|
||||||
// if (key.getHash2() != otherKey.getHash2()) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected Capsule shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
delete shape;
|
delete shape;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//void ShapeInfoTests::runAllTests() {
|
|
||||||
////#define MANUAL_TEST
|
|
||||||
//#ifdef MANUAL_TEST
|
|
||||||
// testHashFunctions();
|
|
||||||
//#endif // MANUAL_TEST
|
|
||||||
// testBoxShape();
|
|
||||||
// testSphereShape();
|
|
||||||
// testCylinderShape();
|
|
||||||
// testCapsuleShape();
|
|
||||||
//}
|
|
||||||
|
|
|
@ -24,41 +24,22 @@ void ShapeManagerTests::testShapeAccounting() {
|
||||||
|
|
||||||
int numReferences = shapeManager.getNumReferences(info);
|
int numReferences = shapeManager.getNumReferences(info);
|
||||||
QCOMPARE(numReferences, 0);
|
QCOMPARE(numReferences, 0);
|
||||||
// if (numReferences != 0) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected ignorant ShapeManager after initialization" << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// create one shape and verify we get a valid pointer
|
// create one shape and verify we get a valid pointer
|
||||||
btCollisionShape* shape = shapeManager.getShape(info);
|
btCollisionShape* shape = shapeManager.getShape(info);
|
||||||
QCOMPARE(shape != nullptr, true);
|
QCOMPARE(shape != nullptr, true);
|
||||||
// if (!shape) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected shape creation for default parameters" << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// verify number of shapes
|
// verify number of shapes
|
||||||
QCOMPARE(shapeManager.getNumShapes(), 1);
|
QCOMPARE(shapeManager.getNumShapes(), 1);
|
||||||
// if (shapeManager.getNumShapes() != 1) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected one shape" << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// reference the shape again and verify that we get the same pointer
|
// reference the shape again and verify that we get the same pointer
|
||||||
btCollisionShape* otherShape = shapeManager.getShape(info);
|
btCollisionShape* otherShape = shapeManager.getShape(info);
|
||||||
QCOMPARE(otherShape, shape);
|
QCOMPARE(otherShape, shape);
|
||||||
// if (otherShape != shape) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected shape* " << (void*)(shape)
|
|
||||||
// << " but found shape* " << (void*)(otherShape) << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// verify number of references
|
// verify number of references
|
||||||
numReferences = shapeManager.getNumReferences(info);
|
numReferences = shapeManager.getNumReferences(info);
|
||||||
int expectedNumReferences = 2;
|
int expectedNumReferences = 2;
|
||||||
QCOMPARE(numReferences, expectedNumReferences);
|
QCOMPARE(numReferences, expectedNumReferences);
|
||||||
// if (numReferences != expectedNumReferences) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected " << expectedNumReferences
|
|
||||||
// << " references but found " << numReferences << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// release all references
|
// release all references
|
||||||
bool released = shapeManager.releaseShape(info);
|
bool released = shapeManager.releaseShape(info);
|
||||||
|
@ -68,67 +49,35 @@ void ShapeManagerTests::testShapeAccounting() {
|
||||||
numReferences--;
|
numReferences--;
|
||||||
}
|
}
|
||||||
QCOMPARE(released, true);
|
QCOMPARE(released, true);
|
||||||
// if (!released) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected shape released" << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// verify shape still exists (not yet garbage collected)
|
// verify shape still exists (not yet garbage collected)
|
||||||
QCOMPARE(shapeManager.getNumShapes(), 1);
|
QCOMPARE(shapeManager.getNumShapes(), 1);
|
||||||
// if (shapeManager.getNumShapes() != 1) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected one shape after release but before garbage collection" << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// verify shape's refcount is zero
|
// verify shape's refcount is zero
|
||||||
numReferences = shapeManager.getNumReferences(info);
|
numReferences = shapeManager.getNumReferences(info);
|
||||||
QCOMPARE(numReferences, 0);
|
QCOMPARE(numReferences, 0);
|
||||||
// if (numReferences != 0) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected refcount = 0 for shape but found refcount = " << numReferences << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// reference the shape again and verify refcount is updated
|
// reference the shape again and verify refcount is updated
|
||||||
otherShape = shapeManager.getShape(info);
|
otherShape = shapeManager.getShape(info);
|
||||||
numReferences = shapeManager.getNumReferences(info);
|
numReferences = shapeManager.getNumReferences(info);
|
||||||
QCOMPARE(numReferences, 1);
|
QCOMPARE(numReferences, 1);
|
||||||
// if (numReferences != 1) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected refcount = 1 for shape but found refcount = " << numReferences << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// verify that shape is not collected as garbage
|
// verify that shape is not collected as garbage
|
||||||
shapeManager.collectGarbage();
|
shapeManager.collectGarbage();
|
||||||
QCOMPARE(shapeManager.getNumShapes(), 1);
|
QCOMPARE(shapeManager.getNumShapes(), 1);
|
||||||
// if (shapeManager.getNumShapes() != 1) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected one shape after release" << std::endl;
|
|
||||||
// }
|
|
||||||
numReferences = shapeManager.getNumReferences(info);
|
numReferences = shapeManager.getNumReferences(info);
|
||||||
QCOMPARE(numReferences, 1);
|
QCOMPARE(numReferences, 1);
|
||||||
// if (numReferences != 1) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected refcount = 1 for shape but found refcount = " << numReferences << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// release reference and verify that it is collected as garbage
|
// release reference and verify that it is collected as garbage
|
||||||
released = shapeManager.releaseShape(info);
|
released = shapeManager.releaseShape(info);
|
||||||
shapeManager.collectGarbage();
|
shapeManager.collectGarbage();
|
||||||
QCOMPARE(shapeManager.getNumShapes(), 0);
|
QCOMPARE(shapeManager.getNumShapes(), 0);
|
||||||
// if (shapeManager.getNumShapes() != 0) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected zero shapes after release" << std::endl;
|
|
||||||
// }
|
|
||||||
QCOMPARE(shapeManager.hasShape(shape), false);
|
QCOMPARE(shapeManager.hasShape(shape), false);
|
||||||
// if (shapeManager.hasShape(shape)) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected ignorant ShapeManager after garbage collection" << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// add the shape again and verify that it gets added again
|
// add the shape again and verify that it gets added again
|
||||||
otherShape = shapeManager.getShape(info);
|
otherShape = shapeManager.getShape(info);
|
||||||
numReferences = shapeManager.getNumReferences(info);
|
numReferences = shapeManager.getNumReferences(info);
|
||||||
QCOMPARE(numReferences, 1);
|
QCOMPARE(numReferences, 1);
|
||||||
// if (numReferences != 1) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected refcount = 1 for shape but found refcount = " << numReferences << std::endl;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeManagerTests::addManyShapes() {
|
void ShapeManagerTests::addManyShapes() {
|
||||||
|
@ -149,10 +98,6 @@ void ShapeManagerTests::addManyShapes() {
|
||||||
btCollisionShape* shape = shapeManager.getShape(info);
|
btCollisionShape* shape = shapeManager.getShape(info);
|
||||||
shapes.push_back(shape);
|
shapes.push_back(shape);
|
||||||
QCOMPARE(shape != nullptr, true);
|
QCOMPARE(shape != nullptr, true);
|
||||||
// if (!shape) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: i = " << i << " null box shape for scale = " << scale << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// make a box
|
// make a box
|
||||||
float radius = 0.5f * s;
|
float radius = 0.5f * s;
|
||||||
|
@ -160,30 +105,17 @@ void ShapeManagerTests::addManyShapes() {
|
||||||
shape = shapeManager.getShape(info);
|
shape = shapeManager.getShape(info);
|
||||||
shapes.push_back(shape);
|
shapes.push_back(shape);
|
||||||
QCOMPARE(shape != nullptr, true);
|
QCOMPARE(shape != nullptr, true);
|
||||||
// if (!shape) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: i = " << i << " null sphere shape for radius = " << radius << std::endl;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify shape count
|
// verify shape count
|
||||||
int numShapes = shapeManager.getNumShapes();
|
int numShapes = shapeManager.getNumShapes();
|
||||||
QCOMPARE(numShapes, 2 * numSizes);
|
QCOMPARE(numShapes, 2 * numSizes);
|
||||||
// if (numShapes != 2 * numSizes) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected numShapes = " << numSizes << " but found numShapes = " << numShapes << std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// release each shape by pointer
|
// release each shape by pointer
|
||||||
for (int i = 0; i < numShapes; ++i) {
|
for (int i = 0; i < numShapes; ++i) {
|
||||||
btCollisionShape* shape = shapes[i];
|
btCollisionShape* shape = shapes[i];
|
||||||
bool success = shapeManager.releaseShape(shape);
|
bool success = shapeManager.releaseShape(shape);
|
||||||
QCOMPARE(success, true);
|
QCOMPARE(success, true);
|
||||||
// if (!success) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: failed to release shape index " << i << std::endl;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify zero references
|
// verify zero references
|
||||||
|
@ -191,11 +123,6 @@ void ShapeManagerTests::addManyShapes() {
|
||||||
btCollisionShape* shape = shapes[i];
|
btCollisionShape* shape = shapes[i];
|
||||||
int numReferences = shapeManager.getNumReferences(shape);
|
int numReferences = shapeManager.getNumReferences(shape);
|
||||||
QCOMPARE(numReferences, 0);
|
QCOMPARE(numReferences, 0);
|
||||||
// if (numReferences != 0) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: expected zero references for shape " << i
|
|
||||||
// << " but refCount = " << numReferences << std::endl;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,10 +137,6 @@ void ShapeManagerTests::addBoxShape() {
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||||
QCOMPARE(shape, otherShape);
|
QCOMPARE(shape, otherShape);
|
||||||
// if (shape != otherShape) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: Box ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeManagerTests::addSphereShape() {
|
void ShapeManagerTests::addSphereShape() {
|
||||||
|
@ -227,10 +150,6 @@ void ShapeManagerTests::addSphereShape() {
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||||
QCOMPARE(shape, otherShape);
|
QCOMPARE(shape, otherShape);
|
||||||
// if (shape != otherShape) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: Sphere ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeManagerTests::addCylinderShape() {
|
void ShapeManagerTests::addCylinderShape() {
|
||||||
|
@ -246,10 +165,6 @@ void ShapeManagerTests::addCylinderShape() {
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||||
QCOMPARE(shape, otherShape);
|
QCOMPARE(shape, otherShape);
|
||||||
// if (shape != otherShape) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: Cylinder ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
|
||||||
// }
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,9 +181,5 @@ void ShapeManagerTests::addCapsuleShape() {
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||||
QCOMPARE(shape, otherShape);
|
QCOMPARE(shape, otherShape);
|
||||||
// if (shape != otherShape) {
|
|
||||||
// std::cout << __FILE__ << ":" << __LINE__
|
|
||||||
// << " ERROR: Capsule ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
|
||||||
// }
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
# Declare dependencies
|
# Declare dependencies
|
||||||
macro (setup_testcase_dependencies)
|
macro (setup_testcase_dependencies)
|
||||||
|
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
link_hifi_libraries(shared)
|
link_hifi_libraries(shared)
|
||||||
|
|
||||||
copy_dlls_beside_windows_executable()
|
copy_dlls_beside_windows_executable()
|
||||||
endmacro ()
|
endmacro ()
|
||||||
|
|
||||||
setup_hifi_testcase()
|
setup_hifi_testcase()
|
|
@ -147,154 +147,3 @@ void MovingPercentileTests::testRunningMedianForN (int n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// NOT THIS:
|
|
||||||
//
|
|
||||||
|
|
||||||
//void MovingPercentileTests::runAllTests() {
|
|
||||||
//
|
|
||||||
// QVector<int> valuesForN;
|
|
||||||
//
|
|
||||||
// valuesForN.append(1);
|
|
||||||
// valuesForN.append(2);
|
|
||||||
// valuesForN.append(3);
|
|
||||||
// valuesForN.append(4);
|
|
||||||
// valuesForN.append(5);
|
|
||||||
// valuesForN.append(10);
|
|
||||||
// valuesForN.append(100);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// QQueue<float> lastNSamples;
|
|
||||||
//
|
|
||||||
// for (int i=0; i<valuesForN.size(); i++) {
|
|
||||||
//
|
|
||||||
// int N = valuesForN.at(i);
|
|
||||||
//
|
|
||||||
// qDebug() << "testing moving percentile with N =" << N << "...";
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// bool fail = false;
|
|
||||||
//
|
|
||||||
// qDebug() << "\t testing running min...";
|
|
||||||
//
|
|
||||||
// lastNSamples.clear();
|
|
||||||
// MovingPercentile movingMin(N, 0.0f);
|
|
||||||
//
|
|
||||||
// for (int s = 0; s < 3*N; s++) {
|
|
||||||
//
|
|
||||||
// float sample = random();
|
|
||||||
//
|
|
||||||
// lastNSamples.push_back(sample);
|
|
||||||
// if (lastNSamples.size() > N) {
|
|
||||||
// lastNSamples.pop_front();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// movingMin.updatePercentile(sample);
|
|
||||||
//
|
|
||||||
// float experimentMin = movingMin.getValueAtPercentile();
|
|
||||||
//
|
|
||||||
// float actualMin = lastNSamples[0];
|
|
||||||
// for (int j = 0; j < lastNSamples.size(); j++) {
|
|
||||||
// if (lastNSamples.at(j) < actualMin) {
|
|
||||||
// actualMin = lastNSamples.at(j);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (experimentMin != actualMin) {
|
|
||||||
// qDebug() << "\t\t FAIL at sample" << s;
|
|
||||||
// fail = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (!fail) {
|
|
||||||
// qDebug() << "\t\t PASS";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// bool fail = false;
|
|
||||||
//
|
|
||||||
// qDebug() << "\t testing running max...";
|
|
||||||
//
|
|
||||||
// lastNSamples.clear();
|
|
||||||
// MovingPercentile movingMax(N, 1.0f);
|
|
||||||
//
|
|
||||||
// for (int s = 0; s < 10000; s++) {
|
|
||||||
//
|
|
||||||
// float sample = random();
|
|
||||||
//
|
|
||||||
// lastNSamples.push_back(sample);
|
|
||||||
// if (lastNSamples.size() > N) {
|
|
||||||
// lastNSamples.pop_front();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// movingMax.updatePercentile(sample);
|
|
||||||
//
|
|
||||||
// float experimentMax = movingMax.getValueAtPercentile();
|
|
||||||
//
|
|
||||||
// float actualMax = lastNSamples[0];
|
|
||||||
// for (int j = 0; j < lastNSamples.size(); j++) {
|
|
||||||
// if (lastNSamples.at(j) > actualMax) {
|
|
||||||
// actualMax = lastNSamples.at(j);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (experimentMax != actualMax) {
|
|
||||||
// qDebug() << "\t\t FAIL at sample" << s;
|
|
||||||
// fail = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (!fail) {
|
|
||||||
// qDebug() << "\t\t PASS";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// bool fail = false;
|
|
||||||
//
|
|
||||||
// qDebug() << "\t testing running median...";
|
|
||||||
//
|
|
||||||
// lastNSamples.clear();
|
|
||||||
// MovingPercentile movingMedian(N, 0.5f);
|
|
||||||
//
|
|
||||||
// for (int s = 0; s < 10000; s++) {
|
|
||||||
//
|
|
||||||
// float sample = random();
|
|
||||||
//
|
|
||||||
// lastNSamples.push_back(sample);
|
|
||||||
// if (lastNSamples.size() > N) {
|
|
||||||
// lastNSamples.pop_front();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// movingMedian.updatePercentile(sample);
|
|
||||||
//
|
|
||||||
// float experimentMedian = movingMedian.getValueAtPercentile();
|
|
||||||
//
|
|
||||||
// int samplesLessThan = 0;
|
|
||||||
// int samplesMoreThan = 0;
|
|
||||||
//
|
|
||||||
// for (int j=0; j<lastNSamples.size(); j++) {
|
|
||||||
// if (lastNSamples.at(j) < experimentMedian) {
|
|
||||||
// samplesLessThan++;
|
|
||||||
// } else if (lastNSamples.at(j) > experimentMedian) {
|
|
||||||
// samplesMoreThan++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// if (!(samplesLessThan <= N/2 && samplesMoreThan <= N-1/2)) {
|
|
||||||
// qDebug() << "\t\t FAIL at sample" << s;
|
|
||||||
// fail = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (!fail) {
|
|
||||||
// qDebug() << "\t\t PASS";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ setup_hifi_project(Widgets OpenGL Network Qml Quick Script)
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_dependency_external_projects(glew)
|
add_dependency_external_projects(glew)
|
||||||
find_package(GLEW REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE ${GLEW_INCLUDE_DIRS})
|
target_include_directories(${TARGET_NAME} PRIVATE ${GLEW_INCLUDE_DIRS})
|
||||||
target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARIES} wsock32.lib opengl32.lib Winmm.lib)
|
target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARIES} wsock32.lib opengl32.lib Winmm.lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
|
|
Loading…
Reference in a new issue