Add failing tests

This commit is contained in:
Dan Balasescu
2023-05-29 18:50:28 +09:00
parent 9206408d84
commit deba719a3b
2 changed files with 96 additions and 0 deletions

View File

@@ -349,6 +349,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=JIT/@EntryIndexedValue">JIT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LTRB/@EntryIndexedValue">LTRB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MD/@EntryIndexedValue">MD5</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NRT/@EntryIndexedValue">NRT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NS/@EntryIndexedValue">NS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OS/@EntryIndexedValue">OS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PM/@EntryIndexedValue">PM</s:String>

View File

@@ -107,6 +107,97 @@ namespace osu.Framework.Tests.Bindables
Assert.That(value, Is.EqualTo(output));
}
// Bindable<int>.Parse(null)
[Test]
public void TestParseNullIntoValueType()
{
Bindable<int> bindable = new Bindable<int>();
Assert.That(() => bindable.Parse(null), Throws.ArgumentNullException);
}
// Bindable<int?>.Parse(null)
[Test]
public void TestParseNullIntoNullableValueType()
{
Bindable<int?> bindable = new Bindable<int?>();
bindable.Parse(null);
Assert.That(bindable.Value, Is.Null);
}
// Bindable<int>.Parse(string.Empty)
[Test]
public void TestParseEmptyStringIntoValueType()
{
Bindable<int> bindable = new Bindable<int>();
bindable.Parse(string.Empty);
Assert.That(bindable.Value, Is.Zero);
}
// Bindable<int?>.Parse(string.Empty)
[Test]
public void TestParseEmptyStringIntoNullableValueType()
{
Bindable<int?> bindable = new Bindable<int?>();
bindable.Parse(string.Empty);
Assert.That(bindable.Value, Is.Null);
}
// Bindable<Class>.Parse(null)
[Test]
public void TestParseNullIntoReferenceType()
{
Bindable<TestClass> bindable = new Bindable<TestClass>();
bindable.Parse(null);
Assert.That(bindable.Value, Is.Null);
}
// Bindable<Class>.Parse(string.Empty)
[Test]
public void TestParseEmptyStringIntoReferenceType()
{
Bindable<TestClass> bindable = new Bindable<TestClass>();
bindable.Parse(string.Empty);
Assert.That(bindable.Value, Is.Null);
}
#nullable enable
// Bindable<Class>.Parse(null) -- NRT
[Test]
public void TestParseNullIntoReferenceTypeWithNRT()
{
Bindable<TestClass> bindable = new Bindable<TestClass>();
bindable.Parse(null);
Assert.That(bindable.Value, Is.Null);
}
// Bindable<Class?>.Parse(null) -- NRT
[Test]
public void TestParseNullIntoNullableReferenceTypeWithNRT()
{
Bindable<TestClass?> bindable = new Bindable<TestClass?>();
bindable.Parse(null);
Assert.That(bindable.Value, Is.Null);
}
// Bindable<Class>.Parse(string.Empty) -- NRT
[Test]
public void TestParseEmptyStringIntoReferenceTypeWithNRT()
{
Bindable<TestClass> bindable = new Bindable<TestClass>();
bindable.Parse(string.Empty);
Assert.That(bindable.Value, Is.Null);
}
// Bindable<Class?>.Parse(string.Empty) -- NRT
[Test]
public void TestParseEmptyStringIntoNullableReferenceTypeWithNRT()
{
Bindable<TestClass?> bindable = new Bindable<TestClass?>();
bindable.Parse(string.Empty);
Assert.That(bindable.Value, Is.Null);
}
#nullable disable
private static IEnumerable<object[]> getParsingConversionTests()
{
var testTypes = new[]
@@ -156,5 +247,9 @@ namespace osu.Framework.Tests.Bindables
}
}
}
private class TestClass
{
}
}
}