public void ParseCommandTest() { var testData = new List <Tuple <int, int[]> >(new Tuple <int, int[]>[] { new Tuple <int, int[]>(1002, new int[] { 2, 0, 1 }), new Tuple <int, int[]>(200146, new int[] { 46, 1, 0, 0, 2 }) }); foreach (var testExample in testData) { var result = IntcodeComputer.ParseCommand(testExample.Item1); Assert.Equal(testExample.Item2.Select(d => (BigInteger)d), result); } }
public void GetParameterModeTest() { var testData = new List <Tuple <int, int, int> >(new Tuple <int, int, int>[] { new Tuple <int, int, int>(1002, 1, 0), new Tuple <int, int, int>(1002, 2, 1), new Tuple <int, int, int>(1002, 3, 0), new Tuple <int, int, int>(200146, 1, 1), new Tuple <int, int, int>(200146, 2, 0), new Tuple <int, int, int>(200146, 3, 0), new Tuple <int, int, int>(200146, 4, 2), new Tuple <int, int, int>(200146, 5, 0), }); foreach (var testExample in testData) { var parsedCommand = IntcodeComputer.ParseCommand(testExample.Item1); var result = IntcodeComputer.GetParameterMode(testExample.Item2, parsedCommand); Assert.Equal(testExample.Item3, result); } }