public void ValidateSerialNumber(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, int i11, int i12, int i13, int i14, int expectedW, int expectedX, int expectedY, int expectedZ)
        {
            var sut = new ArithmeticLogicUnit(REAL_INSTRUCTIONS);

            sut.Input(i1);
            sut.Input(i2);
            sut.Input(i3);
            sut.Input(i4);
            sut.Input(i5);
            sut.Input(i6);
            sut.Input(i7);
            sut.Input(i8);
            sut.Input(i9);
            sut.Input(i10);
            sut.Input(i11);
            sut.Input(i12);
            sut.Input(i13);
            sut.Input(i14);
            sut.Run();

            Assert.Equal(expectedW, sut.W);
            Assert.Equal(expectedX, sut.X);
            Assert.Equal(expectedY, sut.Y);
            Assert.Equal(expectedZ, sut.Z);
        }
        public void MoveInputValueToRegisterW()
        {
            var sut = new ArithmeticLogicUnit("inp w");

            sut.Input(7);
            sut.Run();
            Assert.Equal(7, sut.W);
        }
        public void MoveInputValueToRegisterX()
        {
            var sut = new ArithmeticLogicUnit("inp x");

            sut.Input(5);
            sut.Run();
            Assert.Equal(5, sut.X);
        }
        public void MoveInputValueToRegisterY()
        {
            var sut = new ArithmeticLogicUnit("inp y");

            sut.Input(9);
            sut.Run();
            Assert.Equal(9, sut.Y);
        }
        public void AddZregisterToItselfCorrectly()
        {
            var sut = new ArithmeticLogicUnit("inp z\nadd z z");

            sut.Input(12);
            sut.Run();
            Assert.Equal(24, sut.Z);
        }
        public void ReturnOne_WhenDividingZbyItself()
        {
            var sut = new ArithmeticLogicUnit("inp z\ndiv z z");

            sut.Input(12);
            sut.Run();
            Assert.Equal(1, sut.Z);
        }
        public void MoveInputValueToRegisterZ()
        {
            var sut = new ArithmeticLogicUnit("inp z");

            sut.Input(3);
            sut.Run();
            Assert.Equal(3, sut.Z);
        }
        public void SetYto0_WhenValuesAreNotEqual(string instructions)
        {
            var sut = new ArithmeticLogicUnit(instructions);

            sut.Input(6);
            sut.Input(5);
            sut.Run();
            Assert.Equal(0, sut.Y);
        }
        public void AddRegisterZcorrectly(string instructions)
        {
            var sut = new ArithmeticLogicUnit(instructions);

            sut.Input(5);
            sut.Input(6);
            sut.Run();
            Assert.Equal(11, sut.Z);
        }
        public void DivideRegisterYcorrectly(string instructions)
        {
            var sut = new ArithmeticLogicUnit(instructions);

            sut.Input(12);
            sut.Input(6);
            sut.Run();
            Assert.Equal(2, sut.Y);
        }
        public void LeaveRemainderInRegisterZcorrectly(string instructions)
        {
            var sut = new ArithmeticLogicUnit(instructions);

            sut.Input(12);
            sut.Input(7);
            sut.Run();
            Assert.Equal(5, sut.Z);
        }
        public void MultiplyRegisterZcorrectly(string instructions)
        {
            var sut = new ArithmeticLogicUnit(instructions);

            sut.Input(3);
            sut.Input(3);
            sut.Run();
            Assert.Equal(9, sut.Z);
        }
        public void SetXto1_WhenValuesAreEqual(string instructions)
        {
            var sut = new ArithmeticLogicUnit(instructions);

            sut.Input(6);
            sut.Input(6);
            sut.Run();
            Assert.Equal(1, sut.X);
        }
        public void NegateInputNumberStoredInX(int input, int expectedX)
        {
            var sut = new ArithmeticLogicUnit(@"inp x
mul x -1");

            sut.Input(input);
            sut.Run();
            Assert.Equal(expectedX, sut.X);
        }
        public void VerifyWhetherAvalueIsTripleTheOtherWithRegisterW(string instructions, int firstInput, int secondInput, int expectedResult)
        {
            var sut = new ArithmeticLogicUnit(instructions);

            sut.Input(firstInput);
            sut.Input(secondInput);
            sut.Run();
            Assert.Equal(expectedResult, sut.W);
        }
        public void LeaveZeroAsRemainder_WhenSameRegisterIsUsedForMod(string instructions)
        {
            var sut = new ArithmeticLogicUnit(instructions);

            sut.Input(6);
            sut.Run();
            Assert.Equal(0, sut.W);
            Assert.Equal(0, sut.X);
            Assert.Equal(0, sut.Y);
            Assert.Equal(0, sut.Z);
        }
Exemplo n.º 17
0
        public void RunFirstSectionOfMonadCode(int inputValue, int expectedW, int expectedX, int expectedY, int expectedZ)
        {
            var sut = new ArithmeticLogicUnit(ONE_LOOP_INSTRUCTION);

            sut.Input(inputValue);
            sut.Run();
            Assert.Equal(expectedW, sut.W);
            Assert.Equal(expectedX, sut.X);
            Assert.Equal(expectedY, sut.Y);
            Assert.Equal(expectedZ, sut.Z);
        }
Exemplo n.º 18
0
        [InlineData(9, 9, 9, 1, 21, 645)]   // 99 z = 645
        public void RunSecondSectionOfMonadCode(int firstInput, int secondInput, int expectedW, int expectedX, int expectedY, int expectedZ)
        {
            var sut = new ArithmeticLogicUnit(TWO_LOOP_INSTRUCTIONS);

            sut.Input(firstInput);
            sut.Input(secondInput);
            sut.Run();
            Assert.Equal(expectedW, sut.W);
            Assert.Equal(expectedX, sut.X);
            Assert.Equal(expectedY, sut.Y);
            Assert.Equal(expectedZ, sut.Z);
        }
Exemplo n.º 19
0
        public void RunFifthSectionOfMonadCode(int i1, int i2, int i3, int i4, int i5, int expectedW, int expectedX, int expectedY, int expectedZ)
        {
            var sut = new ArithmeticLogicUnit(FIVE_LOOP_INSTRUCTIONS);

            sut.Input(i1);
            sut.Input(i2);
            sut.Input(i3);
            sut.Input(i4);
            sut.Input(i5);
            sut.Run();
            Assert.Equal(expectedW, sut.W);
            Assert.Equal(expectedX, sut.X);
            Assert.Equal(expectedY, sut.Y);
            Assert.Equal(expectedZ, sut.Z);
        }
Exemplo n.º 20
0
        public void RunTenthSectionOfMonadCode(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, int expectedW, int expectedX, int expectedY, int expectedZ)
        {
            var sut = new ArithmeticLogicUnit(TEN_LOOP_INSTRUCTIONS);

            sut.Input(i1);
            sut.Input(i2);
            sut.Input(i3);
            sut.Input(i4);
            sut.Input(i5);
            sut.Input(i6);
            sut.Input(i7);
            sut.Input(i8);
            sut.Input(i9);
            sut.Input(i10);
            sut.Run();
            Assert.Equal(expectedW, sut.W);
            Assert.Equal(expectedX, sut.X);
            Assert.Equal(expectedY, sut.Y);
            Assert.Equal(expectedZ, sut.Z);
        }
Exemplo n.º 21
0
        public void ConvertValueToBinary(int value, int expectedZ, int expectedY, int expectedX, int expectedW)
        {
            var sut = new ArithmeticLogicUnit(@"inp w
add z w
mod z 2
div w 2
add y w
mod y 2
div w 2
add x w
mod x 2
div w 2
mod w 2");

            sut.Input(value);
            sut.Run();
            Assert.Equal(expectedZ, sut.Z);
            Assert.Equal(expectedY, sut.Y);
            Assert.Equal(expectedX, sut.X);
            Assert.Equal(expectedW, sut.W);
        }