Browse Source

Fix test and make comments clearer

tznind 10 months ago
parent
commit
f40b7b46d5
1 changed files with 20 additions and 4 deletions
  1. 20 4
      UnitTests/Drawing/SixelEncoderTests.cs

+ 20 - 4
UnitTests/Drawing/SixelEncoderTests.cs

@@ -17,10 +17,27 @@ public class SixelEncoderTests
         var expected = "\u001bP" + // Start sixel sequence
         var expected = "\u001bP" + // Start sixel sequence
                             "0;0;0" + // Defaults for aspect ratio and grid size
                             "0;0;0" + // Defaults for aspect ratio and grid size
                             "q" + // Signals beginning of sixel image data
                             "q" + // Signals beginning of sixel image data
-                            "\"1;1;3;2" + // no scaling factors (1x1) and filling 3 runes horizontally and 2 vertically
+                            "\"1;1;12;2" + // no scaling factors (1x1) and filling 12px width with 2 'sixel' height = 12 px high
+
+                            /*
+                             * Definition of the color palette
+                             */
                             "#0;2;100;0;0" + // Red color definition in the format "#<index>;<type>;<R>;<G>;<B>" - 2 means RGB.  The values range 0 to 100
                             "#0;2;100;0;0" + // Red color definition in the format "#<index>;<type>;<R>;<G>;<B>" - 2 means RGB.  The values range 0 to 100
-                            "~~~~$-" + // First 6 rows of red pixels
-                            "~~~~$-" + // Next 6 rows of red pixels
+
+                            /*
+                             * Start of the Pixel data
+                             *   We draw 6 rows at once, so end up with 2 'lines'
+                             *   Both are basically the same and terminate with dollar hyphen (except last row)
+                             *   Format is:
+                             *       #0 (selects to use color palette index 0 i.e. red)
+                             *       !12 (repeat next byte 12 times i.e. the whole length of the row)
+                             *       ~ (the byte 111111 i.e. fill completely)
+                             *       $ (return to start of line)
+                             *       - (move down to next line)
+                             */
+                            "#0!12~$-" +
+                            "#0!12~$" + // Next 6 rows of red pixels
+
                             "\u001b\\"; // End sixel sequence
                             "\u001b\\"; // End sixel sequence
 
 
         // Arrange: Create a 12x12 bitmap filled with red
         // Arrange: Create a 12x12 bitmap filled with red
@@ -44,5 +61,4 @@ public class SixelEncoderTests
 
 
         Assert.Equal (expected, result);
         Assert.Equal (expected, result);
     }
     }
-
 }
 }