Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ jobs:

- name: Build
run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.build_type }}
- name: Tests
run: ctest --test-dir ${{ github.workspace }}/build --output-on-failure -C ${{ matrix.build_type }}
17 changes: 8 additions & 9 deletions .github/workflows/meson-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ jobs:
CC: ${{ matrix.c_compiler }}
CXX: ${{ matrix.cpp_compiler }}

# Uncomment once tests are added:
# - name: Run Tests
# run: meson test -C builddir/ -v
# - name: Upload Test Log
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# name: ${{ matrix.os }}_Meson_Testlog
# path: builddir/meson-logs/testlog.txt
- name: Run Tests
run: meson test -C builddir/ -v
- name: Upload Test Log
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ matrix.os }}_${{ matrix.cpp_compiler }}_Meson_Testlog
path: builddir/meson-logs/testlog.txt
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/spatialaudio)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES ${PROJECT_BINARY_DIR}/config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/spatialaudio)

enable_testing()
add_subdirectory(tests)

#Tarballs generation
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
Expand Down
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ pkg_mod.generate(
description : 'Spatial audio rendering library',
subdirs : 'spatialaudio',
)

subdir('tests')
15 changes: 15 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Tests

function(spaudio_add_test name)
add_executable(${name} "${name}.cpp")
target_link_libraries(${name} PRIVATE spatialaudio-static)
add_test(NAME ${name}
COMMAND $<TARGET_FILE:${name}>)
endfunction()

#add_executable(TestInsideAngleRange tests/TestInsideAngleRange.cpp)
#target_link_libraries(TestInsideAngleRange PRIVATE spatialaudio-static)
#add_test(NAME TestInsideAngleRange
# COMMAND $<TARGET_FILE:TestInsideAngleRange>)

spaudio_add_test(TestInsideAngleRange)
27 changes: 27 additions & 0 deletions tests/TestInsideAngleRange.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#undef NDEBUG
#include <cassert>

#include <Tools.h>

int main() {
assert(spaudio::insideAngleRange(45., -180., 180., 1e-6));
assert(spaudio::insideAngleRange(-30., -90., 90., 1e-6));
assert(spaudio::insideAngleRange(-110., -120., -100.));
assert(spaudio::insideAngleRange(0., -90., 90., 0.));
assert(spaudio::insideAngleRange(91., -90., 90., 0.) == false);
assert(spaudio::insideAngleRange(95., -90., 90., 5.));
assert(spaudio::insideAngleRange(95., 90., -90., 0.));
assert(spaudio::insideAngleRange(85., 90., -90., 0.) == false);
assert(spaudio::insideAngleRange(85., 90., -90., 5.));
assert(spaudio::insideAngleRange(0., 0., 0., 0.));
assert(spaudio::insideAngleRange(1., 0., 0., 0.) == false);
assert(spaudio::insideAngleRange(180., 180., 180., 0.));
assert(spaudio::insideAngleRange(180., -180., -180., 0.));
assert(spaudio::insideAngleRange(179., -180., -180., 0.) == false);
assert(spaudio::insideAngleRange(175., 180., 180., 5.));
assert(spaudio::insideAngleRange(170., 180., 180., 5.) == false);
assert(spaudio::insideAngleRange(180., -180., 180., 0.));
assert(spaudio::insideAngleRange(270., -180., 180., 0.));
assert(spaudio::insideAngleRange(-90., -180., 180., 0.));
assert(spaudio::insideAngleRange(0., -180., 180., 0.));
}
4 changes: 4 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Tests

e = executable('TestInsideAngleRange', 'TestInsideAngleRange.cpp', dependencies: [libspatialaudio_dep])
test('TestInsideAngleRange', e)
Loading