csharp: Raise exception when Array is null.

Reviewers: felipealmeida, vitor.sousa, segfaultxavi

Reviewed By: vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8499
This commit is contained in:
Lauro Moura 2019-04-02 16:47:36 +02:00 committed by Xavi Artigas
parent b41ed254a9
commit 731db8b644
2 changed files with 16 additions and 0 deletions

View File

@ -99,6 +99,11 @@ public class Array<T> : IEnumerable<T>, IDisposable
public Array(IntPtr handle, bool own)
{
if (handle == IntPtr.Zero)
{
throw new ArgumentNullException("Handle can't be null");
}
Handle = handle;
Own = own;
OwnContent = own;
@ -106,6 +111,11 @@ public class Array<T> : IEnumerable<T>, IDisposable
public Array(IntPtr handle, bool own, bool ownContent)
{
if (handle == IntPtr.Zero)
{
throw new ArgumentNullException("Handle can't be null");
}
Handle = handle;
Own = own;
OwnContent = ownContent;

View File

@ -460,6 +460,12 @@ class TestEinaArray
Test.Assert(a.Handle != IntPtr.Zero);
}
public static void create_array_from_null()
{
Test.AssertRaises<ArgumentNullException>(() => new Eina.Array<int>(IntPtr.Zero, false));
Test.AssertRaises<ArgumentNullException>(() => new Eina.Array<int>(IntPtr.Zero, false, false));
}
public static void push_int()
{
var a = new Eina.Array<int>();