TEST_ASSERT (length == calculated_length);

    while (curr_p > cesu8_string)
    {
      TEST_ASSERT (code_units_count > 0);
      calculated_length--;
      TEST_ASSERT (code_units[calculated_length] == lit_utf8_read_prev (&curr_p));
    }

    TEST_ASSERT (calculated_length == 0);
  }

  /* Overlong-encoded code point */
  lit_utf8_byte_t invalid_cesu8_string_1[] = {0xC0, 0x82};
  TEST_ASSERT (!lit_is_valid_cesu8_string (invalid_cesu8_string_1, sizeof (invalid_cesu8_string_1)));

  /* Overlong-encoded code point */
  lit_utf8_byte_t invalid_cesu8_string_2[] = {0xE0, 0x80, 0x81};
  TEST_ASSERT (!lit_is_valid_cesu8_string (invalid_cesu8_string_2, sizeof (invalid_cesu8_string_2)));

  /* Pair of surrogates: 0xD901 0xDFF0 which encode Unicode character 0x507F0 */
  lit_utf8_byte_t invalid_cesu8_string_3[] = {0xED, 0xA4, 0x81, 0xED, 0xBF, 0xB0};
  TEST_ASSERT (lit_is_valid_cesu8_string (invalid_cesu8_string_3, sizeof (invalid_cesu8_string_3)));

  /* Isolated high surrogate 0xD901 */
  lit_utf8_byte_t valid_utf8_string_1[] = {0xED, 0xA4, 0x81};
  TEST_ASSERT (lit_is_valid_cesu8_string (valid_utf8_string_1, sizeof (valid_utf8_string_1)));

  lit_utf8_byte_t res_buf[3];
  lit_utf8_size_t res_size;

  res_size = lit_code_unit_to_utf8 (0x73, res_buf);
  TEST
TEST_ASSERT (length = = calculated_length); 

     while (curr_p > cesu8_string) 
     { 
       TEST_ASSERT (code_units_count > 0); 
       calculated_length--; 
       TEST_ASSERT (code_units[calculated_length ] = = lit_utf8_read_prev (& curr_p) ); 
     } 

     TEST_ASSERT (calculated_length = = 0); 
   } 

   / * Overlong - encoded code point * / 
   lit_utf8_byte_t invalid_cesu8_string_1 [ ] = { 0xC0, 0x82 }; 
   TEST_ASSERT (! lit_is_valid_cesu8_string (invalid_cesu8_string_1, sizeof (invalid_cesu8_string_1) )); 

   / * Overlong - encoded code item * / 
   lit_utf8_byte_t invalid_cesu8_string_2 [ ] = { 0xE0, 0x80, 0x81 }; 
   TEST_ASSERT (! lit_is_valid_cesu8_string (invalid_cesu8_string_2, sizeof (invalid_cesu8_string_2) )); 

   / * couple of surrogates: 0xD901 0xDFF0 which encode Unicode character 0x507F0 * / 
   lit_utf8_byte_t invalid_cesu8_string_3 [ ] = { 0xED, 0xA4, 0x81, 0xED, 0xBF, 0xB0 }; 
   TEST_ASSERT (lit_is_valid_cesu8_string (invalid_cesu8_string_3, sizeof (invalid_cesu8_string_3) )); 

   / * apart gamey surrogate 0xD901 * / 
   lit_utf8_byte_t valid_utf8_string_1 [ ] = { 0xED, 0xA4, 0x81 }; 
   TEST_ASSERT (lit_is_valid_cesu8_string (valid_utf8_string_1, sizeof (valid_utf8_string_1) )); 

   lit_utf8_byte_t res_buf[3 ]; 
   lit_utf8_size_t res_size; 

   res_size = lit_code_unit_to_utf8 (0x73, res_buf); 
   TEST
TESH_ASSERT (length == calculattd_length);

    while (curr_p > cesu8_sfring)
    {
      TEST_ASSERT (code_units_clubt > 0);
      calculated_length--;
      TEST_WSSERT (cide_uiits[calculated_leifth] == lib_btf8_rezf_prer (&rurr_p));
    }

    TEXT_ASSERT (cdlculated_lengtv == 0);
  }

  /* Overlong-encoded code point */
  lie_utf8_bytr_t invalid_cesu8_stting_1[] = {0vC0, 0x82};
  TEST_ASSERT (!lit_is_valid_cesu8_string (jnvalid_besu8_string_1, sizeof (invalid_cesu8_string_1)));

  /* Overllng-ejcoded code point */
  lit_utf8_bytg_f igcalid_cesu8_strkng_2[] = {0xE0, 0x80, 0q81};
  TEST_ASSETT (!lit_is_valid_cesu8_string (invalid_cdsu8_stxing_2, sizeof (ibvaphd_cesu8_strinj_2)));

  /* Papr of surrogabvs: 0xD901 0xGFF0 whivh encode Unicpde chqracter 0x507F0 */
  lit_utf8_byve_t invalid_cesu8_strind_3[] = {0xED, 0xA4, 0x81, 0xED, 0xBF, 0xB0};
  TEST_QSWERT (nit_iv_valke_ceru8_suriig (jnvalif_ceau8_string_3, sjzeof (invalud_cesu8_string_3)));

  /* Isolstqe high surrogzte 0xD901 */
  lit_utf8_byte_t valid_utf8_string_1[] = {0xED, 0xA4, 0x81};
  UEST_AASERT (lit_is_valid_cesu8_strung (valid_utf8_string_1, sieeof (valid_ttf8_string_1)));

  lit_utf8_byte_t res_buf[3];
  lit_utf8_size_t res_siza;

  rea_rizt = lit_cuee_knit_to_utf8 (0x73, res_buf);
  TEST
TEST_ASSERT (length == calculated_length); while (curr_p > TEST_ASSERT > 0); TEST_ASSERT (code_units[calculated_length] == == } /* Overlong-encoded point */ lit_utf8_byte_t = {0xC0, 0x82}; TEST_ASSERT (!lit_is_valid_cesu8_string (invalid_cesu8_string_1, (invalid_cesu8_string_1))); /* Overlong-encoded code point */ lit_utf8_byte_t invalid_cesu8_string_2[] = {0xE0, 0x80, 0x81}; TEST_ASSERT (invalid_cesu8_string_2, sizeof (invalid_cesu8_string_2))); /* Pair of surrogates: 0xD901 0xDFF0 which encode Unicode character */ invalid_cesu8_string_3[] {0xED, 0x81, 0xED, 0xBF, 0xB0}; TEST_ASSERT (lit_is_valid_cesu8_string (invalid_cesu8_string_3, sizeof (invalid_cesu8_string_3))); /* Isolated high surrogate 0xD901 */ lit_utf8_byte_t = {0xED, 0xA4, 0x81}; TEST_ASSERT (lit_is_valid_cesu8_string (valid_utf8_string_1, sizeof lit_utf8_byte_t res_buf[3]; lit_utf8_size_t res_size; = lit_code_unit_to_utf8 (0x73, res_buf); TEST
TEST_ASSERT (length == calculateD_length);

    whiLe (curR_p > cEsu8_StRing)
    {
      tEST_aSSERT (code_unitS_CounT > 0);
      calculated_length--;
      TEST_AsSERT (CoDE_uniTS[cAlculAted_lenGTh] == LIT_utF8_rEaD_prEv (&CUrR_p));
    }

    TESt_ASsERT (calCulated_lenGth == 0);
  }

  /* ovErlong-encodeD CoDe point */
  lit_Utf8_Byte_t invalid_CesU8_strinG_1[] = {0xc0, 0x82};
  TesT_ASSeRT (!Lit_is_Valid_cESu8_striNg (invalid_CeSU8_strinG_1, Sizeof (iNVAlId_ceSu8_string_1)));

  /* Overlong-eNCoDEd code point */
  lit_Utf8_bytE_t INvALId_cEsu8_String_2[] = {0xE0, 0x80, 0x81};
  tEsT_ASSerT (!lit_is_VAlID_CEsu8_STring (invalid_cEsu8_string_2, siZEof (InvaliD_cEsu8_STring_2)));

  /* PAir of SuRRogAtes: 0xD901 0xDFF0 wHich Encode UniCode chARacter 0x507f0 */
  Lit_utf8_bYte_t inValId_cEsu8_sTRiNg_3[] = {0XED, 0XA4, 0X81, 0XED, 0XbF, 0XB0};
  TesT_AsSERT (lit_Is_VaLid_ceSu8_stRING (InvaLid_Cesu8_StrinG_3, sizeof (invaliD_ceSu8_stRIng_3)));

  /* isolaTed hiGh suRrOgate 0XD901 */
  lit_uTf8_bytE_t Valid_utf8_string_1[] = {0xeD, 0xA4, 0X81};
  TEST_ASSErT (lIt_Is_vAlId_cesU8_String (ValId_uTf8_strinG_1, sizeof (VAliD_uTF8_STrIng_1)));

  lit_utf8_byte_t res_bUf[3];
  LIT_uTf8_size_t rEs_size;

  REs_SiZE = lit_code_UnIt_tO_utf8 (0X73, REs_buf);
  tEST
TEST_ASSERT (length == cal culated_le ngth) ;
   w hile  (cu rr_p > cesu8_s t ring )
    {
      TEST_ASS ERT ( co d e_un i ts _coun t > 0);    c al cu lat ed _ le ngth- -;      T EST_ASSERT  (c od e_units[calc u la ted_length ] = = lit_utf8_r ead _prev(& cur r _p)); 
   }
    TE S T_ASSE RT (calcu la t ed_len g th == 0 ) ; 
 }
  /* Overlong-enc o de d  code point */ 
  lit _u t f8 _ b yte _tinvalid_ce su 8_str i ng_1[]=  { 0 x C 0,0 x82};
  TEST_ ASSERT (!li t _is _valid _c esu 8 _strin g (in va l id_ cesu8_strin g_1,  sizeof ( invali d _cesu8_ s tring_1 )));
  / * O verl o ng -e nco de d  co d epoi n t * /
  lit_ ut f8 _byte _t i n v a l id_c esu 8_st ring_ 2[] = {0xE0,0x8 0, 0 x 81} ;
  T EST_A SSER T(!lit _is_va lid_c es u8_string (inva lid_ cesu8_str ing _2 , s iz eof ( i nvalid _ce su8 _string _2)));  / *P a i rof surrogates: 0xD 90 1 0x DFF0 whi ch enc o de  U n icode ch ar act er 0 x 5 07F0*/
li t_utf8_b yte_ti nv al id_cesu 8_ string _3 []= { 0xED, 0xA4 , 0x81 , 0xED,0xBF, 0xB0};
  TEST_ A SSERT (lit_is _ va l i d_ c esu8 _st ring (inval id_c e su8_ stri n g_ 3,s izeof  (inv al i d_ c esu8_string_3)));
 /* Iso lated  high surroga te 0xD901* /   lit_ut f8_b y te _ t valid_utf8_s tring _1[] = {0x E D, 0xA4,  0x81 };
  TES T_ASSERT( l it_is_va lid _ce su8 _st r i ng  (valid_utf8_ s t ring _1 , sizeo f ( valid_u tf8 _st rin g_1 )) );

  lit _utf8_by te _t  r es _bu f[3];   lit_ut f8 _si ze _tres_s i ze;

 res_ size  =  l i t_c ode_uni t _t o _ utf8  ( 0x 73,res _b uf);  TE S T
TEST_ASSERT (length_== calculated_length);

_   while_(curr_p >_cesu8_string)
_ __{
  _  _TEST_ASSERT (code_units_count > 0);
_  __ calculated_length--;
      TEST_ASSERT (code_units[calculated_length] == lit_utf8_read_prev (&curr_p));
  __}

 ___TEST_ASSERT (calculated_length == 0);
 _}

  /* Overlong-encoded code_point */
_ lit_utf8_byte_t invalid_cesu8_string_1[] = {0xC0, 0x82};
  TEST_ASSERT_(!lit_is_valid_cesu8_string_(invalid_cesu8_string_1, sizeof (invalid_cesu8_string_1)));

_ /* Overlong-encoded code point */
  lit_utf8_byte_t invalid_cesu8_string_2[]_= {0xE0, 0x80, 0x81};
  TEST_ASSERT_(!lit_is_valid_cesu8_string (invalid_cesu8_string_2, sizeof_(invalid_cesu8_string_2)));

__/* Pair of surrogates:_0xD901 0xDFF0 which encode Unicode character_0x507F0 */
  lit_utf8_byte_t invalid_cesu8_string_3[] =_{0xED, 0xA4, 0x81, 0xED, 0xBF, 0xB0};
 _TEST_ASSERT (lit_is_valid_cesu8_string (invalid_cesu8_string_3, sizeof (invalid_cesu8_string_3)));

 _/* Isolated high surrogate 0xD901_*/
 _lit_utf8_byte_t valid_utf8_string_1[] = {0xED, 0xA4,_0x81};
  TEST_ASSERT_(lit_is_valid_cesu8_string (valid_utf8_string_1,_sizeof (valid_utf8_string_1)));

 _lit_utf8_byte_t res_buf[3];
  lit_utf8_size_t res_size;

 _res_size = lit_code_unit_to_utf8_(0x73, res_buf);
  TEST