Skip to content

Commit

Permalink
[VisualBasic] Fix tests for Android (dotnet#41378)
Browse files Browse the repository at this point in the history
Remove some empty tests and add data for others. Resolves dotnet#37066
  • Loading branch information
ehasis authored Aug 26, 2020
1 parent 7140c60 commit f1f6b3c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 108 deletions.
36 changes: 0 additions & 36 deletions src/libraries/Microsoft.VisualBasic.Core/tests/CharTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,13 @@ public void FromObject_ThrowsInvalidCastException(object value)
Assert.Throws<InvalidCastException>(() => CharType.FromObject(value));
}

[Theory]
[MemberData(nameof(FromObject_Overflow_TestData))]
public void FromObject_ThrowsOverflowException(object value)
{
Assert.Throws<OverflowException>(() => CharType.FromObject(value));
}

[Theory]
[MemberData(nameof(FromString_TestData))]
public void FromString(string value, char expected)
{
Assert.Equal(expected, CharType.FromString(value));
}

[Theory]
[MemberData(nameof(FromString_Invalid_TestData))]
public void FromString_ThrowsInvalidCastException(string value)
{
Assert.Throws<InvalidCastException>(() => CharType.FromString(value));
}

[Theory]
[MemberData(nameof(FromString_Overflow_TestData))]
public void FromString_ThrowsOverflowException(string value)
{
Assert.Throws<OverflowException>(() => CharType.FromString(value));
}

public static IEnumerable<object[]> FromObject_TestData()
{
// char.
Expand Down Expand Up @@ -159,11 +138,6 @@ public static IEnumerable<object[]> FromObject_Invalid_TestData()
yield return new object[] { new object() };
}

public static IEnumerable<object[]> FromObject_Overflow_TestData()
{
yield break;
}

public static IEnumerable<object[]> FromString_TestData()
{
yield return new object[] { null, char.MinValue };
Expand All @@ -186,15 +160,5 @@ public static IEnumerable<object[]> FromString_TestData()
yield return new object[] { "18446744073709551616", '1' };
yield return new object[] { "1844674407370955161618446744073709551616", '1' };
}

public static IEnumerable<object[]> FromString_Invalid_TestData()
{
yield break;
}

public static IEnumerable<object[]> FromString_Overflow_TestData()
{
yield break;
}
}
}
66 changes: 21 additions & 45 deletions src/libraries/Microsoft.VisualBasic.Core/tests/ConversionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,17 +476,23 @@ public static IEnumerable<object[]> Hex_Long_TestData()

public static IEnumerable<object[]> Hex_Single_TestData()
{
yield break; // Add more...
yield return new object[] { (float)0, "0" };
yield return new object[] { (float)1, "1" };
yield return new object[] { (float)15, "F" };
}

public static IEnumerable<object[]> Hex_Double_TestData()
{
yield break; // Add more...
yield return new object[] { (double)0, "0" };
yield return new object[] { (double)1, "1" };
yield return new object[] { (double)15, "F" };
}

public static IEnumerable<object[]> Hex_Decimal_TestData()
{
yield break; // Add more...
yield return new object[] { (decimal)0, "0" };
yield return new object[] { (decimal)1, "1" };
yield return new object[] { (decimal)15, "F" };
}

[Theory]
Expand Down Expand Up @@ -812,17 +818,23 @@ public static IEnumerable<object[]> Oct_Long_TestData()

public static IEnumerable<object[]> Oct_Single_TestData()
{
yield break; // Add more...
yield return new object[] { (float)0, "0" };
yield return new object[] { (float)1, "1" };
yield return new object[] { (float)15, "17" };
}

public static IEnumerable<object[]> Oct_Double_TestData()
{
yield break; // Add more...
yield return new object[] { (double)0, "0" };
yield return new object[] { (double)1, "1" };
yield return new object[] { (double)15, "17" };
}

public static IEnumerable<object[]> Oct_Decimal_TestData()
{
yield break; // Add more...
yield return new object[] { (decimal)0, "0" };
yield return new object[] { (decimal)1, "1" };
yield return new object[] { (decimal)15, "17" };
}

[Theory]
Expand Down Expand Up @@ -893,34 +905,13 @@ public void Val_Char_Int(char value, int expected)
Assert.Equal(expected, Conversion.Val(value));
}

[Theory]
[MemberData(nameof(Val_Char_ArgumentException_TestData))]
public void Val_ArgumentException_Char(char value)
{
Assert.Throws<ArgumentException>(() => Conversion.Val(value));
}

[Theory]
[MemberData(nameof(Val_Char_OverflowException_TestData))]
public void Val_OverflowException_Char(char value)
{
Assert.Throws<OverflowException>(() => Conversion.Val(value));
}

[Theory]
[MemberData(nameof(Val_String_TestData))]
public void Val_String_Double(string value, double expected)
{
Assert.Equal(expected, Conversion.Val(value));
}

[Theory]
[MemberData(nameof(Val_String_ArgumentException_TestData))]
public void Val_ArgumentException_String(string value)
{
Assert.Throws<ArgumentException>(() => Conversion.Val(value));
}

[Theory]
[MemberData(nameof(Val_String_InvalidCastException_TestData))]
public void Val_InvalidCastException(string value)
Expand All @@ -943,12 +934,12 @@ public static IEnumerable<object[]> Val_Object_TestData()

public static IEnumerable<object[]> Val_Object_ArgumentException_TestData()
{
yield break; // Add more...
yield return new object[] { new object() };
}

public static IEnumerable<object[]> Val_Object_OverflowException_TestData()
{
yield break; // Add more...
yield return new object[] { "123456e789" };
}

public static IEnumerable<object[]> Val_Char_TestData()
Expand All @@ -968,16 +959,6 @@ public static IEnumerable<object[]> Val_Char_TestData()
yield return new object[] { char.MaxValue, 0 };
}

public static IEnumerable<object[]> Val_Char_ArgumentException_TestData()
{
yield break; // Add more...
}

public static IEnumerable<object[]> Val_Char_OverflowException_TestData()
{
yield break; // Add more...
}

public static IEnumerable<object[]> Val_String_TestData()
{
yield return new object[] { null, 0.0 };
Expand Down Expand Up @@ -1019,11 +1000,6 @@ public static IEnumerable<object[]> Val_String_TestData()
yield return new object[] { "&O37777777777&", -1.0 };
}

public static IEnumerable<object[]> Val_String_ArgumentException_TestData()
{
yield break; // Add more...
}

public static IEnumerable<object[]> Val_String_InvalidCastException_TestData()
{
yield return new object[] { "1.0%" };
Expand All @@ -1032,7 +1008,7 @@ public static IEnumerable<object[]> Val_String_InvalidCastException_TestData()

public static IEnumerable<object[]> Val_String_OverflowException_TestData()
{
yield break; // Add more...
yield return new object[] { "123456e789" };
}

public static IEnumerable<object[]> Various_ArgumentException_TestData()
Expand Down
26 changes: 1 addition & 25 deletions src/libraries/Microsoft.VisualBasic.Core/tests/DateTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ public void FromObject_ThrowsInvalidCastException(object value)
Assert.Throws<InvalidCastException>(() => DateType.FromObject(value));
}

[Theory]
[MemberData(nameof(FromObject_Overflow_TestData))]
public void FromObject_ThrowsOverflowException(object value)
{
Assert.Throws<OverflowException>(() => DateType.FromObject(value));
}

[Theory]
[MemberData(nameof(FromString_TestData))]
public void FromString(string value, DateTime expected)
Expand All @@ -63,13 +56,6 @@ public void FromString_ThrowsInvalidCastException(string value)
Assert.Throws<InvalidCastException>(() => DateType.FromString(value));
}

[Theory]
[MemberData(nameof(FromString_Overflow_TestData))]
public void FromString_ThrowsOverflowException(string value)
{
Assert.Throws<OverflowException>(() => DateType.FromString(value));
}

public static IEnumerable<object[]> FromObject_TestData()
{
// null.
Expand Down Expand Up @@ -172,12 +158,7 @@ public static IEnumerable<object[]> FromObject_NotSupported_TestData()

public static IEnumerable<object[]> FromObject_Invalid_TestData()
{
yield break;
}

public static IEnumerable<object[]> FromObject_Overflow_TestData()
{
yield break;
yield return new object[] { new object() };
}

public static IEnumerable<object[]> FromString_TestData()
Expand Down Expand Up @@ -208,10 +189,5 @@ public static IEnumerable<object[]> FromString_Invalid_TestData()
yield return new object[] { "false" };
yield return new object[] { "invalid" };
}

public static IEnumerable<object[]> FromString_Overflow_TestData()
{
yield break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public static IEnumerable<object[]> FromString_Invalid_TestData()

public static IEnumerable<object[]> FromString_Overflow_TestData()
{
yield break;
yield return new object[] { "12345678901234567890" };
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public static IEnumerable<object[]> FromObject_Invalid_TestData()

public static IEnumerable<object[]> FromObject_Overflow_TestData()
{
yield break;
yield return new object[] { "1234567890123456789012345678901234567890" };
}

public static IEnumerable<object[]> FromString_TestData()
Expand Down

0 comments on commit f1f6b3c

Please sign in to comment.