mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-07 22:36:49 -04:00
Add Wav test
This commit is contained in:
parent
b5dbfa4a58
commit
acc8a919a9
@ -1,10 +1,11 @@
|
|||||||
# simple command-line tests
|
# simple command-line tests
|
||||||
SET(CLI_TESTS
|
SET(CLI_TESTS
|
||||||
|
test_error
|
||||||
|
test_optional
|
||||||
test_pointrect
|
test_pointrect
|
||||||
test_pointrect_constexpr
|
test_pointrect_constexpr
|
||||||
test_rwops
|
test_rwops
|
||||||
test_optional
|
test_wav
|
||||||
test_error
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# live tests require X11 display and/or audio output
|
# live tests require X11 display and/or audio output
|
||||||
|
38
tests/test_wav.cc
Normal file
38
tests/test_wav.cc
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include <SDL2/SDL_main.h>
|
||||||
|
|
||||||
|
#include <SDL2pp/Wav.hh>
|
||||||
|
|
||||||
|
#include "testing.h"
|
||||||
|
|
||||||
|
using namespace SDL2pp;
|
||||||
|
|
||||||
|
BEGIN_TEST(int, char*[])
|
||||||
|
Wav wav(TESTDATA_DIR "/test.wav");
|
||||||
|
|
||||||
|
{
|
||||||
|
EXPECT_EQUAL(wav.GetLength(), (Uint32)121044);
|
||||||
|
EXPECT_TRUE(wav.GetBuffer() != nullptr);
|
||||||
|
EXPECT_TRUE((const Uint8*)wav.GetBuffer() == (Uint8*)wav.GetBuffer());
|
||||||
|
|
||||||
|
const AudioSpec& spec = wav.GetSpec();
|
||||||
|
|
||||||
|
EXPECT_EQUAL(spec.Get()->freq, 44100);
|
||||||
|
EXPECT_EQUAL((int)spec.Get()->channels, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Move tests
|
||||||
|
Uint8* buf = wav.GetBuffer();
|
||||||
|
|
||||||
|
Wav wav1(std::move(wav));
|
||||||
|
EXPECT_TRUE(wav1.GetBuffer() == buf);
|
||||||
|
EXPECT_TRUE(wav.GetBuffer() == nullptr);
|
||||||
|
|
||||||
|
std::swap(wav, wav1);
|
||||||
|
EXPECT_TRUE(wav.GetBuffer() == buf);
|
||||||
|
EXPECT_TRUE(wav1.GetBuffer() == nullptr);
|
||||||
|
|
||||||
|
wav = std::move(wav); // self-move
|
||||||
|
EXPECT_TRUE(wav.GetBuffer() == buf);
|
||||||
|
}
|
||||||
|
END_TEST()
|
Loading…
x
Reference in New Issue
Block a user