Ejemplo n.º 1
0
		public void TestHuge()
		{
			using (var b = new ThreadSafeWriteQueue(1024))
			{
				var pos = b.Allocate(1024 - 2);
				b.Commit(pos);
				var a = b.ReadMessage();
				Assert.AreEqual(pos, a);
				Assert.AreEqual(-1, b.ReadMessage());

				pos = b.Allocate(1024 - 2);
				b.Commit(pos);
				a = b.ReadMessage();
				Assert.AreEqual(pos, a);
				Assert.AreEqual(-1, b.ReadMessage());

				Assert.Throws<OverflowException>(() => b.Allocate(1024 - 1));
			}
		}
Ejemplo n.º 2
0
		public void TestInt64()
		{
			using (var b = new ThreadSafeWriteQueue(10))
			{
				var pos = b.Allocate(9);

				this.TestInt64(b, pos, long.MinValue);
				this.TestInt64(b, pos, long.MaxValue);
				this.TestInt64(b, pos, int.MaxValue);
				this.TestInt64(b, pos, int.MinValue);
				this.TestInt64(b, pos, 0);
			}
		}
Ejemplo n.º 3
0
		public void TestFloat()
		{
			using (var b = new ThreadSafeWriteQueue(10))
			{
				var pos = b.Allocate(9);

				this.TestFloat(b, pos, float.MinValue);
				this.TestFloat(b, pos, float.MaxValue);
				this.TestFloat(b, pos, float.Epsilon);
				this.TestFloat(b, pos, 0);
				this.TestFloat(b, pos, 1.1f);
			}
		}
Ejemplo n.º 4
0
		public void TestSafeRead()
		{
			using (var b = new ThreadSafeWriteQueue(8))
			{
				b.Commit(b.Allocate(2));
				b.Commit(b.Allocate(2));
				b.ReadMessage();
				Assert.Throws<OverflowException>(() => b.Allocate(2));
				b.ReadMessage();
				b.Commit(b.Allocate(2));
			}
		}
Ejemplo n.º 5
0
		public void TestOverflow()
		{
			using (var b = new ThreadSafeWriteQueue(1024))
			{
				int i = 1024 / (2);
				while (i > 1)
				{
					b.Commit(b.Allocate(1));
					--i;
				}
				Assert.Throws<OverflowException>(() => b.Allocate(1));
			}
		}