Files
osu-framework/osu.Framework.Tests/Bindables/BindableFloatTest.cs
2018-04-11 16:34:32 +09:00

67 lines
2.0 KiB
C#

// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
using NUnit.Framework;
using osu.Framework.Configuration;
namespace osu.Framework.Tests.Bindables
{
[TestFixture]
public class BindableFloatTest
{
[TestCase(0)]
[TestCase(-0)]
[TestCase(1)]
[TestCase(-105.123f)]
[TestCase(105.123f)]
[TestCase(float.MinValue)]
[TestCase(float.MaxValue)]
public void TestSet(float value)
{
var bindable = new BindableFloat { Value = value };
Assert.AreEqual(value, bindable.Value);
}
[TestCase("0", 0f)]
[TestCase("1", 1f)]
[TestCase("-0", 0f)]
[TestCase("-105.123", -105.123f)]
[TestCase("105.123", 105.123f)]
public void TestParsingString(string value, float expected)
{
var bindable = new BindableFloat();
bindable.Parse(value);
Assert.AreEqual(expected, bindable.Value);
}
[TestCase("0", -10, 10, 0)]
[TestCase("1", -10, 10, 1)]
[TestCase("-0", -10, 10, 0)]
[TestCase("-105.123", -10, 10, -10)]
[TestCase("105.123", -10, 10, 10)]
public void TestParsingStringWithRange(string value, float minValue, float maxValue, float expected)
{
var bindable = new BindableFloat { MinValue = minValue, MaxValue = maxValue };
bindable.Parse(value);
Assert.AreEqual(expected, bindable.Value);
}
[TestCase(0)]
[TestCase(-0)]
[TestCase(1)]
[TestCase(-105.123f)]
[TestCase(105.123f)]
[TestCase(float.MinValue)]
[TestCase(float.MaxValue)]
public void TestParsingFloat(float value)
{
var bindable = new BindableFloat();
bindable.Parse(value);
Assert.AreEqual(value, bindable.Value);
}
}
}