using System; using System.Collections.Generic; using System.Text; using UnitTestSharp; using Sunweaver.Commands.Abstracts; using Sunweaver.Commands.UnaryMath; using Sunweaver.DataPrototypes; namespace Sunweaver.UnitTests.Commands.UnaryMath { public class randTest : TestFixture { BasePair bp = new rand(); VirtualMachine VM; public override void TestSetup() { VM = new VirtualMachine(); } public void TestRandom() { bool flag = true; for (int i = 0; i < 100; i++) { VM.Stack.Push(10); bp.Implementation(VM); int result = VM.Stack.Pop(); if(result < 0 || result > 9) flag = false; } CheckEqual(flag, true); } public void TestNegativeRandom() { bool flag = true; for (int i = 0; i < 100; i++) { VM.Stack.Push(-10); bp.Implementation(VM); int result = VM.Stack.Pop(); if (result > 0 || result < -9) flag = false; } CheckEqual(flag, true); } } }