using System; using System.Collections.Generic; using System.Text; using UnitTestSharp; using Sunweaver.Commands.Abstracts; using Sunweaver.Commands; using Sunweaver.VM; namespace Sunweaver.UnitTesting.Commands { public class storeTests : TestFixture { BasePair bp = new store(); VirtualMachine VM; public override void TestSetup() { VM = new VirtualMachine(); } public void StoresCorrectly() { VM.Stack.Push(25); VM.Stack.Push(30); bp.Implementation(VM); CheckEqual((short)25, VM.Memory[30]); } public void NameTest() { CheckEqual("store", bp.ToString()); } public void NegativeLocation() { VM.Stack.Push(25); VM.Stack.Push(-30); bp.Implementation(VM); CheckEqual((short)25, VM.Memory[30]); } public void OverflowValue() { VM.Stack.Push(2500001); VM.Stack.Push(30); bp.Implementation(VM); CheckEqual((short)1, VM.Memory[30]); } public void OverflowLocation() { VM.Stack.Push(25); VM.Stack.Push(3000001); bp.Implementation(VM); CheckEqual((short)25, VM.Memory[1]); } public void DoesNotFizzleWhenFalse() { VM.BoolStack.Push(false); VM.Stack.Push(25); VM.Stack.Push(30); bp.Implementation(VM); CheckEqual((short)25, VM.Memory[30]); } public void StoreToZeroDoesNothing() { VM.Stack.Push(25); VM.Stack.Push(0); bp.Implementation(VM); } } }