Ported some of the python fuzz tests to C#

* Refactored the test runner to use attribute based test discovery
* Ported value and vtable/object fuzzing tests from python to C#
This commit is contained in:
evolutional
2015-10-18 17:08:39 -04:00
parent 94680f5483
commit 9d66af6efc
11 changed files with 1067 additions and 40 deletions

View File

@@ -39,6 +39,25 @@ namespace FlatBuffers.Test
}
}
public class AssertArrayFailedException : Exception
{
private readonly int _index;
private readonly object _expected;
private readonly object _actual;
public AssertArrayFailedException(int index, object expected, object actual)
{
_index = index;
_expected = expected;
_actual = actual;
}
public override string Message
{
get { return string.Format("Expected {0} at index {1} but saw {2}", _expected, _index, _actual); }
}
}
public class AssertUnexpectedThrowException : Exception
{
private readonly object _expected;
@@ -64,6 +83,22 @@ namespace FlatBuffers.Test
}
}
public static void ArrayEqual<T>(T[] expected, T[] actual)
{
if (expected.Length != actual.Length)
{
throw new AssertFailedException(expected, actual);
}
for(var i = 0; i < expected.Length; ++i)
{
if (!expected[i].Equals(actual[i]))
{
throw new AssertArrayFailedException(i, expected, actual);
}
}
}
public static void IsTrue(bool value)
{
if (!value)