mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
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.
44 lines
1.1 KiB
C#
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}");
|
|
}
|
|
}
|