|
| 1 | +#include <CSFML/Audio/Listener.h> |
| 2 | + |
| 3 | +#include <catch2/catch_test_macros.hpp> |
| 4 | + |
| 5 | +TEST_CASE("[Audio] sfListener") |
| 6 | +{ |
| 7 | + SECTION("sfListenerCone") |
| 8 | + { |
| 9 | + constexpr sfListenerCone cone{}; |
| 10 | + STATIC_CHECK(cone.innerAngle == 0); |
| 11 | + STATIC_CHECK(cone.outerAngle == 0); |
| 12 | + STATIC_CHECK(cone.outerGain == 0); |
| 13 | + } |
| 14 | + |
| 15 | + SECTION("Set/get global volume") |
| 16 | + { |
| 17 | + CHECK(sfListener_getGlobalVolume() == 100); |
| 18 | + sfListener_setGlobalVolume(42); |
| 19 | + CHECK(sfListener_getGlobalVolume() == 42); |
| 20 | + } |
| 21 | + |
| 22 | + SECTION("Set/get position") |
| 23 | + { |
| 24 | + sfVector3f position = sfListener_getPosition(); |
| 25 | + CHECK(position.x == 0); |
| 26 | + CHECK(position.y == 0); |
| 27 | + CHECK(position.z == 0); |
| 28 | + sfListener_setPosition({3, 4, 5}); |
| 29 | + position = sfListener_getPosition(); |
| 30 | + CHECK(position.x == 3); |
| 31 | + CHECK(position.y == 4); |
| 32 | + CHECK(position.z == 5); |
| 33 | + } |
| 34 | + |
| 35 | + SECTION("Set/get direction") |
| 36 | + { |
| 37 | + sfVector3f direction = sfListener_getDirection(); |
| 38 | + CHECK(direction.x == 0); |
| 39 | + CHECK(direction.y == 0); |
| 40 | + CHECK(direction.z == -1); |
| 41 | + sfListener_setDirection({6, 7, 8}); |
| 42 | + direction = sfListener_getDirection(); |
| 43 | + CHECK(direction.x == 6); |
| 44 | + CHECK(direction.y == 7); |
| 45 | + CHECK(direction.z == 8); |
| 46 | + } |
| 47 | + |
| 48 | + SECTION("Set/get velocity") |
| 49 | + { |
| 50 | + sfVector3f velocity = sfListener_getVelocity(); |
| 51 | + CHECK(velocity.x == 0); |
| 52 | + CHECK(velocity.y == 0); |
| 53 | + CHECK(velocity.z == 0); |
| 54 | + sfListener_setVelocity({9, 10, 11}); |
| 55 | + velocity = sfListener_getVelocity(); |
| 56 | + CHECK(velocity.x == 9); |
| 57 | + CHECK(velocity.y == 10); |
| 58 | + CHECK(velocity.z == 11); |
| 59 | + } |
| 60 | + |
| 61 | + SECTION("Set/get cone") |
| 62 | + { |
| 63 | + sfListenerCone cone = sfListener_getCone(); |
| 64 | + CHECK(cone.innerAngle == 360); |
| 65 | + CHECK(cone.outerAngle == 360); |
| 66 | + CHECK(cone.outerGain == 1); |
| 67 | + sfListener_setCone({15, 30, 0.5f}); |
| 68 | + cone = sfListener_getCone(); |
| 69 | + CHECK(cone.innerAngle == 15); |
| 70 | + CHECK(cone.outerAngle == 30); |
| 71 | + CHECK(cone.outerGain == 0.5f); |
| 72 | + } |
| 73 | + |
| 74 | + SECTION("Set/get up vector") |
| 75 | + { |
| 76 | + sfVector3f upVector = sfListener_getUpVector(); |
| 77 | + CHECK(upVector.x == 0); |
| 78 | + CHECK(upVector.y == 1); |
| 79 | + CHECK(upVector.z == 0); |
| 80 | + sfListener_setUpVector({12, 13, 14}); |
| 81 | + upVector = sfListener_getUpVector(); |
| 82 | + CHECK(upVector.x == 12); |
| 83 | + CHECK(upVector.y == 13); |
| 84 | + CHECK(upVector.z == 14); |
| 85 | + } |
| 86 | +} |
0 commit comments