Skip to content

Commit

Permalink
Merge pull request #116 from jhasse/sound-unittest
Browse files Browse the repository at this point in the history
Add a unittest for playing audio
  • Loading branch information
jhasse authored Feb 13, 2024
2 parents dd6de06 + 1607355 commit e781443
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
name: Windows
on: [push]
jobs:
clang-cl:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- name: Configure
run: cmake -Bbuild -G"Ninja Multi-Config" -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl
- name: Build (Debug)
run: cmake --build build --config Debug
- name: Unittest (Debug)
run: |
build/Debug/jngl-unittest Drawable
build/Debug/jngl-unittest ImageData
build/Debug/jngl-unittest FinallyTest
build/Debug/jngl-unittest halfLoadTest
build/Debug/jngl-unittest getBinaryPath
build/Debug/jngl-unittest readAsset
- name: Build (Release)
run: cmake --build build --config Release
- name: Unittest (Release)
run: |
build/Release/jngl-unittest Drawable
build/Release/jngl-unittest ImageData
build/Release/jngl-unittest FinallyTest
build/Release/jngl-unittest halfLoadTest
build/Release/jngl-unittest getBinaryPath
build/Release/jngl-unittest readAsset
msvc:
runs-on: windows-2022
steps:
Expand All @@ -9,8 +37,24 @@ jobs:
run: cmake -Bbuild
- name: Build (Debug)
run: cmake --build build --config Debug
- name: Unittest (Debug)
run: |
build/Debug/jngl-unittest Drawable
build/Debug/jngl-unittest ImageData
build/Debug/jngl-unittest FinallyTest
build/Debug/jngl-unittest halfLoadTest
build/Debug/jngl-unittest getBinaryPath
build/Debug/jngl-unittest readAsset
- name: Build (Release)
run: cmake --build build --config Release
- name: Unittest (Release)
run: |
build/Release/jngl-unittest Drawable
build/Release/jngl-unittest ImageData
build/Release/jngl-unittest FinallyTest
build/Release/jngl-unittest halfLoadTest
build/Release/jngl-unittest getBinaryPath
build/Release/jngl-unittest readAsset
- name: Configure (UWP)
run: cmake -Bbuild-uwp -DCMAKE_SYSTEM_NAME=WindowsStore '-DCMAKE_SYSTEM_VERSION=10.0'
- name: Build (UWP, Debug)
Expand Down
20 changes: 20 additions & 0 deletions src/unittest/SoundTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2024 Jan Niklas Hasse <[email protected]>
// For conditions of distribution and use, see copyright notice in LICENSE.txt

#include "../jngl/sound.hpp"

#include <jngl.hpp>

#include <boost/ut.hpp>

namespace {
boost::ut::suite _ = [] {
using namespace boost::ut; // NOLINT
"Sound"_test = [] {
jngl::play("../data/test.ogg");
expect(jngl::isPlaying("../data/test.ogg"));
jngl::stop("../data/test.ogg");
expect(!jngl::isPlaying("../data/test.ogg"));
};
};
} // namespace
9 changes: 7 additions & 2 deletions src/unittest/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// Copyright 2018-2023 Jan Niklas Hasse <[email protected]>
// Copyright 2018-2024 Jan Niklas Hasse <[email protected]>
// For conditions of distribution and use, see copyright notice in LICENSE.txt

#include <boost/ut.hpp>
#include <cassert>

int main() {
int main(int argc, char** argv) {
assert(argc <= 2);
if (argc == 2) {
boost::ut::cfg<boost::ut::override> = { .filter = argv[1] };
}
return boost::ut::cfg<>.run(); // explicitly run registered test suites
}

0 comments on commit e781443

Please sign in to comment.