mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-03 16:24:13 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user