public void testSetLength() { IndexedNumsStream ins = new IndexedNumsStream(600); ins.SetLength(500); Assert.AreEqual(500, ins.Length); }
public void testSetPositionPastStream() { IndexedNumsStream ins = new IndexedNumsStream(10); ins.Seek(999, System.IO.SeekOrigin.End); Assert.AreEqual(ins.Position, ins.Length); }
public void testConstructor() { IndexedNumsStream ins = new IndexedNumsStream(long.MinValue); long expected = 0; long actual = ins.Length; Assert.AreEqual(expected, actual); }
public void NegativeStreamLengthTest() { // Set streams length to arbitrary negative size. IndexedNumsStream indexedNumsStream = new IndexedNumsStream(-4352451245L); // Should become 0 Assert.AreEqual(indexedNumsStream.Length, 0); }
public void EndOfStreamTest() { IndexedNumsStream indexedNumStream = new IndexedNumsStream(10L); byte[] buffer = new byte[6]; Console.WriteLine(indexedNumStream.Read(buffer, 0, 4)); Assert.Pass(); }
public void NegativePositionTest() { IndexedNumsStream indexedNumsStream = new IndexedNumsStream(long.MaxValue); // Set the position to an arbitrary negative number. indexedNumsStream.Position = -9999; // Should come out to 0. Assert.AreEqual(indexedNumsStream.Position, 0); }
public void testStreamLeftToRead() { IndexedNumsStream ins = new IndexedNumsStream(7); byte[] buffer = new byte[100]; ins.Seek(4, System.IO.SeekOrigin.Begin); int nBytes = ins.Read(buffer, 0, 7); Assert.AreEqual(3, nBytes); }
public void testEndOfStream() { IndexedNumsStream ins = new IndexedNumsStream(600); byte[] buffer = new byte[100]; ins.Seek(0, System.IO.SeekOrigin.End); int actual = ins.Read(buffer, 10, 10); Assert.AreEqual(0, actual); }
public void testNullBuffer() { IndexedNumsStream ins = new IndexedNumsStream(600); byte[] buffer = null; try{ ins.Read(buffer, 10, 10); } catch (NullReferenceException) { Assert.IsTrue(true); } }
public void PositionGreaterThanLengthTest() { const long LENGTH = 10; IndexedNumsStream indexedNumsStream = new IndexedNumsStream(LENGTH); // Set the position above the stream's length. indexedNumsStream.Position = LENGTH + 1000; // Should come out to the streams length. Assert.LessOrEqual(indexedNumsStream.Position, indexedNumsStream.Length); }
public void IndexedNumsStream_TooBigCount_ExpectPass() { //arrange byte[] buffer = new byte[256]; IndexedNumsStream test = new IndexedNumsStream(long.MaxValue); //act test.Read(buffer, 0, 2086165146); //assert Assert.AreEqual(2086165146 % 256, buffer[2086165145]); }
public void IndexedNumsStream_negativeCount_Expect0() { //arrange byte[] buffer = new byte[256]; IndexedNumsStream test = new IndexedNumsStream(256); //act test.Read(buffer, 0, -1); //assert Assert.AreEqual(0, buffer[0]); }
public void testStreamStructure() { IndexedNumsStream ins = new IndexedNumsStream(600); byte[] buffer = new byte[500]; ins.Read(buffer, 0, 500); for (int i = 0; i < buffer.Length; i++) { Assert.AreEqual(i % 256, buffer [i]); } }
public void ReadTest() { NumsStream = new IndexedNumsStream(255); Assert.IsNotNull(NumsStream); Assert.AreEqual(NumsStream.Length, 255); NumsStream = new IndexedNumsStream(1000); Assert.AreEqual(255, NumsStream.Length); NumsStream.SetLength(-500); Assert.AreEqual(0, NumsStream.Length); }
public void IndexedNumsStream_Regular256Buff_ExpectPass() { //arrange byte[] buffer = new byte[256]; IndexedNumsStream test = new IndexedNumsStream(256); //act test.Read(buffer, 0, 256); //assert for (int i = 0; i < 256; i++) { Assert.AreEqual(i % 256, buffer[i]); } }
public void IndexReadWithNoOffset(int offset, int count) { //Arrange IndexedNumsStream stream = new IndexedNumsStream(); byte[] buffer = new byte[1000]; //Act stream.Read(buffer, offset, count); //Assert Assert.AreEqual(stream.Length, 255); Assert.AreEqual(0, buffer[0]); Assert.AreEqual(1, buffer[1]); Assert.AreEqual(2, buffer[2]); }
public void testArgumentOutOfRangeException() { IndexedNumsStream ins = new IndexedNumsStream(600); byte[] buffer = new byte[100]; try{ ins.Read(buffer, -10, 10); } catch (ArgumentOutOfRangeException) { Assert.IsTrue(true); } try{ ins.Read(buffer, 10, -10); } catch (ArgumentOutOfRangeException) { Assert.IsTrue(true); } }
public void IndexReadToEnd(int offset, int count) { //Arrange IndexedNumsStream stream = new IndexedNumsStream(30); byte[] buffer = new byte[1000]; stream.Position = 29; //Act stream.Read(buffer, offset, count); //Assert Assert.AreEqual(30, stream.Length); Assert.AreEqual(29, buffer[0]); Assert.AreEqual(30, buffer[1]); Assert.AreEqual(0, buffer[2]); }
public void IndexReadOverModBoundry(int offset, int count) { //Arrange IndexedNumsStream stream = new IndexedNumsStream(550); byte[] buffer = new byte[1000]; stream.Position = 254; //Act stream.Read(buffer, offset, count); //Assert Assert.AreEqual(550, stream.Length); Assert.AreEqual(254, buffer[0]); Assert.AreEqual(255, buffer[1]); Assert.AreEqual(0, buffer[2]); }
public void BufferTest() { IndexedNumsStream indexedNumsStream = new IndexedNumsStream(long.MaxValue); byte[] buffer = new byte[byte.MaxValue * 2]; indexedNumsStream.Read(buffer, 0, buffer.Length); for (var b = 0; b < buffer.Length; ++b) { if (buffer[b] != (b % (byte.MaxValue + 1))) { Console.WriteLine(b); Assert.Fail(); } } Assert.Pass(); }
public void canBufferHoldData() { IndexedNumsStream ins = new IndexedNumsStream(600); byte[] buffer = new byte[10]; try{ ins.Read(buffer, 5, 6); Assert.IsTrue(false); } catch (ArgumentException) { Assert.IsTrue(true); } try{ ins.Read(buffer, 5, 5); } catch (ArgumentException) { Assert.IsTrue(true); } }
public static void Main(string[] args) { Console.WriteLine("INS Testing:"); byte[] buf1 = new byte[257]; byte[] buf2 = new byte[BSIZE]; IndexedNumsStream ins = new IndexedNumsStream(SSIZE); ins.Read(buf1, 0, 257); ins.Read(buf2, 0, COUNT); for (int i = 0; i < 257; i++) { Console.WriteLine(buf1[i]); } for (int i = 0; i < BSIZE; i++) { Console.WriteLine(buf2[i]); } }
public void testSeekBegin() { IndexedNumsStream ins = new IndexedNumsStream(600); System.IO.SeekOrigin origin = System.IO.SeekOrigin.Begin; //1) long newPosition = ins.Seek(999, origin); Assert.AreEqual(newPosition, 600); //2) newPosition = ins.Seek(-9999, origin); Assert.AreEqual(0, newPosition); //3) //position should now be at 0. newPosition = ins.Seek(50, origin); Assert.AreEqual(50, newPosition); }
static void Main(string[] args) { //Program p = new Program(); //test NumberedTextWriter NumberedTextWriter ntw = new NumberedTextWriter(Console.Out); ntw.WriteLine("Hello World!"); ntw.WriteLine("Hi!"); //test IndexedNumsStream, IndexedNumsStream ins = new IndexedNumsStream(0); byte[] buffer = new byte[512]; ins.SetLength(512); ins.Read(buffer, 0, 512); foreach (byte num in buffer) { Console.WriteLine(num); } }
public void testMaxStreamLength() { IndexedNumsStream ins = new IndexedNumsStream(long.MaxValue); Assert.AreEqual(long.MaxValue, ins.Length); }
public void testCanSeek() { IndexedNumsStream ins = new IndexedNumsStream(600); Assert.AreEqual(true, ins.CanSeek); }