LCOV - code coverage report
Current view: top level - src/rendering - cset.cc (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 15 15 100.0 %
Date: 2022-06-15 20:16:21 Functions: 5 7 71.4 %
Branches: 4 4 100.0 %

           Branch data     Line data    Source code
       1                 :            : #ifdef RUN_TESTS
       2                 :            : # include <gtest/gtest.h>
       3                 :            : #endif
       4                 :            : /** @file rendering/cset.cc
       5                 :            :  * @brief Defines TranslateCSet()
       6                 :            :  */
       7                 :            : 
       8                 :            : #include "cset.hh"
       9                 :            : 
      10                 :       1025 : char32_t TranslateCSet(char32_t c, int cset)
      11                 :            : {
      12         [ +  + ]:       1025 :     switch(cset)
      13                 :            :     {
      14                 :            :         case 0:
      15                 :            :         default:
      16                 :            :             return c;
      17                 :        513 :         case 1: // DEC Graphics
      18                 :        513 :         {
      19                 :        513 :             static const unsigned short table[32] =
      20                 :            :             {
      21                 :            :                 0x25ae, /* black vertical rectangle           */
      22                 :            :                 0x25c6, /* black diamond                      */
      23                 :            :                 0x2592, /* medium shade                       */
      24                 :            :                 0x2409, /* symbol for horizontal tabulation   */
      25                 :            :                 0x240c, /* symbol for form feed               */
      26                 :            :                 0x240d, /* symbol for carriage return         */
      27                 :            :                 0x240a, /* symbol for line feed               */
      28                 :            :                 0x00b0, /* degree sign                        */
      29                 :            :                 0x00b1, /* plus-minus sign                    */
      30                 :            :                 0x2424, /* symbol for newline                 */
      31                 :            :                 0x240b, /* symbol for vertical tabulation     */
      32                 :            :                 0x2518, /* box drawings light up and left     */
      33                 :            :                 0x2510, /* box drawings light down and left   */
      34                 :            :                 0x250c, /* box drawings light down and right  */
      35                 :            :                 0x2514, /* box drawings light up and right    */
      36                 :            :                 0x253c, /* box drawings light vertical and horizontal */
      37                 :            :                 0x23ba, /* box drawings scan 1                */
      38                 :            :                 0x23bb, /* box drawings scan 3                */
      39                 :            :                 0x2500, /* box drawings light horizontal      */
      40                 :            :                 0x23bc, /* box drawings scan 7                */
      41                 :            :                 0x23bd, /* box drawings scan 9                */
      42                 :            :                 0x251c, /* box drawings light vertical and right      */
      43                 :            :                 0x2524, /* box drawings light vertical and left       */
      44                 :            :                 0x2534, /* box drawings light up and horizontal       */
      45                 :            :                 0x252c, /* box drawings light down and horizontal     */
      46                 :            :                 0x2502, /* box drawings light vertical        */
      47                 :            :                 0x2264, /* less-than or equal to              */
      48                 :            :                 0x2265, /* greater-than or equal to           */
      49                 :            :                 0x03c0, /* greek small letter pi              */
      50                 :            :                 0x2260, /* not equal to                       */
      51                 :            :                 0x00a3, /* pound sign                         */
      52                 :            :                 0x00b7, /* middle dot                         */
      53                 :            :             };
      54         [ +  + ]:        513 :             return (c >= 0x5F && c <= 0x7E) ? table[c - 0x5F] : c;
      55                 :            :         }
      56                 :            :     }
      57                 :            : }
      58                 :            : 
      59                 :            : #ifdef RUN_TESTS
      60                 :          3 : TEST(TranslateCSet, zero_ok)
      61                 :            : {
      62                 :        513 :     for(unsigned a=0; a<512; ++a) EXPECT_EQ(TranslateCSet(a,0), a);
      63                 :          1 : }
      64                 :          3 : TEST(TranslateCSet, one_ok)
      65                 :            : {
      66                 :         96 :     for(unsigned a=0; a<0x5F; ++a) EXPECT_EQ(TranslateCSet(a,1), a);
      67                 :        386 :     for(unsigned a=0x7F; a<512; ++a) EXPECT_EQ(TranslateCSet(a,1), a);
      68                 :         32 :     for(unsigned a=0x5F; a<0x7E; ++a) EXPECT_NE(TranslateCSet(a,1), a);
      69                 :          1 :     EXPECT_EQ(TranslateCSet(0x61, 1), 0x2592u);
      70                 :          1 : }
      71                 :            : #endif

Generated by: LCOV version 1.16