ByteBuffers: Changed the tests back to their original state (testing for NullReferenceException and ArgumentOutOfRangeException)
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2e9cf78d Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2e9cf78d Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2e9cf78d Branch: refs/heads/master Commit: 2e9cf78d8c4f1cd6ea851c75b7ba28cfbba0d048 Parents: 3a55298 Author: Shad Storhaug <[email protected]> Authored: Sun Apr 30 21:37:59 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Mon May 1 04:48:37 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs | 8 ++++---- src/Lucene.Net.Tests/Support/IO/TestByteBuffer2.cs | 8 ++++---- src/Lucene.Net.Tests/Support/IO/TestLongBuffer.cs | 12 ++++++------ src/Lucene.Net/Support/IO/ByteBuffer.cs | 5 +++-- src/Lucene.Net/Support/IO/LongBuffer.cs | 7 ++++--- 5 files changed, 21 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2e9cf78d/src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs b/src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs index 1334f3c..27c1883 100644 --- a/src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs +++ b/src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs @@ -32,14 +32,14 @@ namespace Lucene.Net.Support.IO protected ByteBuffer buf; - public override void SetUp() + public override void SetUp() { buf = ByteBuffer.Allocate(10); loadTestData1(buf); baseBuf = buf; } - public override void TearDown() + public override void TearDown() { base.TearDown(); } @@ -611,7 +611,7 @@ namespace Lucene.Net.Support.IO buf.Clear(); ByteBuffer @readonly = buf.AsReadOnlyBuffer(); ByteBuffer duplicate = buf.Duplicate(); - assertEquals(buf.GetHashCode(),@readonly.GetHashCode()); + assertEquals(buf.GetHashCode(), @readonly.GetHashCode()); duplicate.SetPosition(buf.Capacity / 2); assertTrue(buf.GetHashCode() != duplicate.GetHashCode()); } @@ -2524,7 +2524,7 @@ namespace Lucene.Net.Support.IO ByteBuffer.Wrap(new byte[10], int.MaxValue, 2); fail("Should throw IndexOutOfRangeException"); //$NON-NLS-1$ } - catch (IndexOutOfRangeException e) + catch (ArgumentOutOfRangeException e) { } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2e9cf78d/src/Lucene.Net.Tests/Support/IO/TestByteBuffer2.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Support/IO/TestByteBuffer2.cs b/src/Lucene.Net.Tests/Support/IO/TestByteBuffer2.cs index b4d9ba1..87ed5b4 100644 --- a/src/Lucene.Net.Tests/Support/IO/TestByteBuffer2.cs +++ b/src/Lucene.Net.Tests/Support/IO/TestByteBuffer2.cs @@ -687,19 +687,19 @@ namespace Lucene.Net.Support.IO ck(b, b.Limit, offset + length); // The offset must be non-negative and no larger than <array.length>. - tryCatch(ba, typeof(IndexOutOfRangeException), () => + tryCatch(ba, typeof(ArgumentOutOfRangeException), () => { ByteBuffer.Wrap(ba, -1, ba.Length); }); - tryCatch(ba, typeof(IndexOutOfRangeException), () => + tryCatch(ba, typeof(ArgumentOutOfRangeException), () => { ByteBuffer.Wrap(ba, ba.Length + 1, ba.Length); }); - tryCatch(ba, typeof(IndexOutOfRangeException), () => + tryCatch(ba, typeof(ArgumentOutOfRangeException), () => { ByteBuffer.Wrap(ba, 0, -1); }); - tryCatch(ba, typeof(IndexOutOfRangeException), () => + tryCatch(ba, typeof(ArgumentOutOfRangeException), () => { ByteBuffer.Wrap(ba, 0, ba.Length + 1); }); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2e9cf78d/src/Lucene.Net.Tests/Support/IO/TestLongBuffer.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Support/IO/TestLongBuffer.cs b/src/Lucene.Net.Tests/Support/IO/TestLongBuffer.cs index dcd4f26..5a64656 100644 --- a/src/Lucene.Net.Tests/Support/IO/TestLongBuffer.cs +++ b/src/Lucene.Net.Tests/Support/IO/TestLongBuffer.cs @@ -486,29 +486,29 @@ namespace Lucene.Net.Support.IO ck(b, b.Limit, offset + length); // The offset must be non-negative and no larger than <array.length>. - tryCatch(ba, typeof(IndexOutOfRangeException), () => + tryCatch(ba, typeof(ArgumentOutOfRangeException), () => { Int64Buffer.Wrap(ba, -1, ba.Length); }); - tryCatch(ba, typeof(IndexOutOfRangeException), () => + tryCatch(ba, typeof(ArgumentOutOfRangeException), () => { Int64Buffer.Wrap(ba, ba.Length + 1, ba.Length); }); - tryCatch(ba, typeof(IndexOutOfRangeException), () => + tryCatch(ba, typeof(ArgumentOutOfRangeException), () => { Int64Buffer.Wrap(ba, 0, -1); }); - tryCatch(ba, typeof(IndexOutOfRangeException), () => + tryCatch(ba, typeof(ArgumentOutOfRangeException), () => { Int64Buffer.Wrap(ba, 0, ba.Length + 1); }); // A NullPointerException will be thrown if the array is null. - tryCatch(ba, typeof(ArgumentNullException), () => + tryCatch(ba, typeof(NullReferenceException), () => { Int64Buffer.Wrap((long[])null, 0, 5); }); - tryCatch(ba, typeof(ArgumentNullException), () => + tryCatch(ba, typeof(NullReferenceException), () => { Int64Buffer.Wrap((long[])null); }); http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2e9cf78d/src/Lucene.Net/Support/IO/ByteBuffer.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Support/IO/ByteBuffer.cs b/src/Lucene.Net/Support/IO/ByteBuffer.cs index c3473c4..021ce02 100644 --- a/src/Lucene.Net/Support/IO/ByteBuffer.cs +++ b/src/Lucene.Net/Support/IO/ByteBuffer.cs @@ -101,7 +101,7 @@ namespace Lucene.Net.Support.IO int actualLength = array.Length; if ((start < 0) || (length < 0) || ((long)start + (long)length > actualLength)) { - throw new IndexOutOfRangeException(); + throw new ArgumentOutOfRangeException(); } ByteBuffer buf = new ReadWriteHeapByteBuffer(array); @@ -265,7 +265,8 @@ namespace Lucene.Net.Support.IO /// </returns> public override bool Equals(object other) { - if (!(other is ByteBuffer)) { + if (!(other is ByteBuffer)) + { return false; } ByteBuffer otherBuffer = (ByteBuffer)other; http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2e9cf78d/src/Lucene.Net/Support/IO/LongBuffer.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Support/IO/LongBuffer.cs b/src/Lucene.Net/Support/IO/LongBuffer.cs index ac59c6f..82255c7 100644 --- a/src/Lucene.Net/Support/IO/LongBuffer.cs +++ b/src/Lucene.Net/Support/IO/LongBuffer.cs @@ -73,11 +73,11 @@ namespace Lucene.Net.Support.IO { if (array == null) { - throw new ArgumentNullException(); + throw new NullReferenceException(); } if (start < 0 || len < 0 || (long)len + (long)start > array.Length) { - throw new IndexOutOfRangeException(); + throw new ArgumentOutOfRangeException(); } Int64Buffer buf = new ReadWriteInt64ArrayBuffer(array); @@ -138,7 +138,8 @@ namespace Lucene.Net.Support.IO public override bool Equals(object other) { - if (!(other is Int64Buffer)) { + if (!(other is Int64Buffer)) + { return false; } Int64Buffer otherBuffer = (Int64Buffer)other;
