예제 #1
0
        public unsafe void Pop_Item_After_Expanding_Success()
        {
            var expected = new TestStruct()
            {
                X = 3, Y = 1
            };

            ExpandableStack <TestStruct> sut = stackalloc TestStruct[1];

            sut.Push(expected);

            sut.Expand(stackalloc TestStruct[1]);

            sut.Push(new TestStruct()
            {
                X = 1, Y = 1
            });

            sut.Pop();
            var testStruct = sut.Pop();

            Assert.AreEqual(0, sut.Count);

            Assert.AreEqual(expected.X, testStruct.X);
            Assert.AreEqual(expected.Y, testStruct.Y);
        }
예제 #2
0
 public unsafe void Pop_Item_Fail()
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         ExpandableStack <TestStruct> sut = stackalloc TestStruct[1];
         sut.Pop();
     });
 }
예제 #3
0
        public unsafe void Modify_Popped_Item_Success()
        {
            var expected = new TestStruct()
            {
                X = 3, Y = 1
            };

            ExpandableStack <TestStruct> sut = stackalloc TestStruct[1];

            sut.Push(expected);

            ref var actual = ref sut.Peek();
예제 #4
0
        public unsafe void Push_Item_Fail()
        {
            var expected = new TestStruct()
            {
                X = 3, Y = 1
            };

            ExpandableStack <TestStruct> sut = stackalloc TestStruct[1];

            sut.Push(expected);
            Assert.AreEqual(1, sut.Count);

            Assert.False(sut.Push(expected));
            Assert.AreEqual(1, sut.Count);
        }
예제 #5
0
        public unsafe void Push_Item_Success()
        {
            var expected = new TestStruct()
            {
                X = 3, Y = 1
            };

            ExpandableStack <TestStruct> sut = stackalloc TestStruct[1];

            Assert.AreEqual(1, sut.Capacity);
            Assert.AreEqual(0, sut.Count);

            Assert.True(sut.Push(expected));
            Assert.AreEqual(1, sut.Count);
        }
예제 #6
0
        public unsafe void Pop_Item_Success()
        {
            var expected = new TestStruct()
            {
                X = 3, Y = 1
            };

            ExpandableStack <TestStruct> sut = stackalloc TestStruct[1];

            sut.Push(expected);

            var testStruct = sut.Pop();

            Assert.AreEqual(0, sut.Count);

            Assert.AreEqual(3, testStruct.X);
            Assert.AreEqual(1, testStruct.Y);
        }