Exemplo n.º 1
0
 public function testEncode()
 {
     $num_pixels = self::TEST_WIDTH * self::TEST_HEIGHT;
     $frame = array_fill(0, $num_pixels, 0);
     $set_pixels = [2, 3, 9, 10];
     $expected = ['frame' => []];
     foreach ($set_pixels as $sp) {
         $frame[$sp] = 1;
         $expected['frame'][(string) $sp] = JsonFrameEncoder::COLOR_FG;
     }
     $this->assertEquals(json_encode($expected), $this->encoder->encodeFrame($frame));
 }
Exemplo n.º 2
0
 public function testEncodeFrame()
 {
     $num_pixels = self::TEST_WIDTH * self::TEST_HEIGHT;
     $frame = array_fill(0, $num_pixels, 0);
     $set_pixels = [2 => 2, 3 => 3, 9 => 10, 10 => 11];
     $expected = self::TEST_BLANK_ENCODED;
     foreach ($set_pixels as $sp => $ep) {
         $frame[$sp] = 1;
         $expected[$ep] = AsciiFrameEncoder::ENCODED_PIXEL_ON;
     }
     $this->assertEquals($expected, $this->encoder->encodeFrame($frame));
 }