public void Digit_patterns_are_binary_coded() { var patterns = Program.DigitPatterns; var validChars = Program.ValidChars; void assert(string digit, int code) { var pattern = AsciiPattern.New(validChars); foreach (var ch in digit) { pattern.PushChar(ch); } Assert.That(pattern.Code, Is.EqualTo(code)); } assert(patterns[0], 0b010_101_111); assert(patterns[1], 0b000_001_001); assert(patterns[2], 0b010_011_110); assert(patterns[3], 0b010_011_011); assert(patterns[4], 0b000_111_001); assert(patterns[5], 0b010_110_011); assert(patterns[6], 0b010_110_111); assert(patterns[7], 0b010_001_001); assert(patterns[8], 0b010_111_111); assert(patterns[9], 0b010_111_011); }
private AsciiNumber(Config config, int lineNo) { _config = config; _lineNo = lineNo; _patterns = new IAsciiPattern[config.NoOfDigits]; for (int i = 0; i < config.NoOfDigits; i++) { _patterns[i] = AsciiPattern.New(config.ValidChars); } }
public static int[] BuildDigitCodes(string[] patterns) { var codes = new int[10]; for (int digit = 0; digit < 10; digit++) { var pattern = AsciiPattern.New(ValidChars); foreach (var ch in DigitPatterns[digit]) { pattern.PushChar(ch); } codes[digit] = pattern.Code; } return(codes); }