Files
RobustToolbox/Robust.Shared.Tests/Audio/AudioGainVolume_Test.cs
PJB3005 788e9386fd Split up test project
Robust.UnitTesting was both ALL tests for RT, and also API surface for content tests.

Tests are now split into separate projects as appropriate, and the API side has also been split off.
2025-12-16 01:36:53 +01:00

44 lines
1.1 KiB
C#

using NUnit.Framework;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Maths;
namespace Robust.Shared.Tests.Audio;
[TestFixture]
public sealed class AudioGainVolume_Test
{
private static float[] _gainValues = new[]
{
1f,
0.5f,
0f,
};
private static float[] _volumeValues = new[]
{
-100f,
-3f,
0f,
1f,
100f,
};
[Test, TestCaseSource(nameof(_gainValues))]
public void GainCalculationTest(float value)
{
var volume = SharedAudioSystem.GainToVolume(value);
var gain = SharedAudioSystem.VolumeToGain(volume);
Assert.That(MathHelper.CloseTo(value, gain, 0.01f), $"Expected {value} and found {volume}");
}
[Test, TestCaseSource(nameof(_volumeValues))]
public void VolumeCalculationTest(float value)
{
var gain = SharedAudioSystem.VolumeToGain(value);
var volume = SharedAudioSystem.GainToVolume(gain);
Assert.That(MathHelper.CloseTo(value, volume, 0.01f), $"Expected {value} and found {volume}");
}
}