private void Check(IQuadAdder adder,byte x,byte y, bool cIn, bool cOut, byte s) { string message = String.Format("(x={0},y={1},cIn={2}) => (cOut={3},s={4})",x,y,cIn,cOut,s); Tuple<byte,byte,bool> input = new Tuple<byte, byte, bool>(x,y,cIn); Tuple<byte,bool> result = adder.Output(input); Assert.AreEqual(s,result.Item1, message); Assert.AreEqual(cOut, result.Item2, message); }
private void DoLoop(IQuadAdder adder,bool cIn) { // ohne carry in (cIn) for(byte x = 0; x<16; x++) for(byte y= 0; y<16; y++) { byte result = (byte)(x + y + (cIn ? 1:0 )); bool cOut = (result & 0x10) > 0; result &= 0x0F; Check(adder, x,y,cIn,cOut,result); Check(adder, y,x,cIn,cOut,result); } }