package door import "testing" func TestConvert(t *testing.T) { // From: https://en.wikipedia.org/wiki/Code_page_437 // Special cases: \x08 (backspace), \x07 (bell), \x0a, \x0d, \x1b ANSI Escape code BinaryMap := map[string][]byte{ // "\u0000\u263A\u263B\u2665\u2666\u2663\u2660\u2022": {0, 1, 2, 3, 4, 5, 6, 7}, "\u0000\u263A\u263B\u2665\u2666\u2663\u2660\x07": {0, 1, 2, 3, 4, 5, 6, 7}, // "\u25D8\u25CB\u25D9\u2642\u2640\u266A\u266B\u263C": {8, 9, 10, 11, 12, 13, 14, 15}, "\x08\u25CB\x0a\u2642\u2640\x0d\u266B\u263C": {8, 9, 10, 11, 12, 13, 14, 15}, "\u25BA\u25C4\u2195\u203C\u00B6\u00A7\u25AC\u21A8": {16, 17, 18, 19, 20, 21, 22, 23}, // "\u2191\u2193\u2192\u2190\u221F\u2194\u25B2\u25BC": {24, 25, 26, 27, 28, 29, 30, 31}, "\u2191\u2193\u2192\x1b\u221F\u2194\u25B2\u25BC": {24, 25, 26, 27, 28, 29, 30, 31}, "\u0020\u0021\u0022\u0023\u0024\u0025\u0026\u0027": {32, 33, 34, 35, 36, 37, 38, 39}, "\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F": {40, 41, 42, 43, 44, 45, 46, 47}, "\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037": {48, 49, 50, 51, 52, 53, 54, 55}, "\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F": {56, 57, 58, 59, 60, 61, 62, 63}, "\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047": {64, 65, 66, 67, 68, 69, 70, 71}, "\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F": {72, 73, 74, 75, 76, 77, 78, 79}, "\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057": {80, 81, 82, 83, 84, 85, 86, 87}, "\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F": {88, 89, 90, 91, 92, 93, 94, 95}, "\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067": {96, 97, 98, 99, 100, 101, 102, 103}, "\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F": {104, 105, 106, 107, 108, 109, 110, 111}, "\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077": {112, 113, 114, 115, 116, 117, 118, 119}, "\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u2302": {120, 121, 122, 123, 124, 125, 126, 127}, "\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7": {128, 129, 130, 131, 132, 133, 134, 135}, "\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5": {136, 137, 138, 139, 140, 141, 142, 143}, "\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9": {144, 145, 146, 147, 148, 149, 150, 151}, "\u00FF\u00D6\u00DC\u00A2\u00A3\u00A5\u20A7\u0192": {152, 153, 154, 155, 156, 157, 158, 159}, "\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA": {160, 161, 162, 163, 164, 165, 166, 167}, "\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB": {168, 169, 170, 171, 172, 173, 174, 175}, "\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556": {176, 177, 178, 179, 180, 181, 182, 183}, "\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510": {184, 185, 186, 187, 188, 189, 190, 191}, "\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F": {192, 193, 194, 195, 196, 197, 198, 199}, "\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567": {200, 201, 202, 203, 204, 205, 206, 207}, "\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B": {208, 209, 210, 211, 212, 213, 214, 215}, "\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580": {216, 217, 218, 219, 220, 221, 222, 223}, "\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4": {224, 225, 226, 227, 228, 229, 230, 231}, "\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229": {232, 233, 234, 235, 236, 237, 238, 239}, "\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248": {240, 241, 242, 243, 244, 245, 246, 247}, "\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0": {248, 249, 250, 251, 252, 253, 254, 255}, } for output, binary := range BinaryMap { value := CP437_to_Unicode(string(binary)) if output != value { t.Errorf("CP437_to_Unicode: Expected %#v (%#v), got %#v", output, binary, value) } } }