Files
harbour-core/tests/base64.prg
vszakats a4a357a18b 2013-03-15 11:12 UTC+0100 Viktor Szakats (harbour syenar.net)
* /harbour/* -> /*
    * moved whole Harbour source tree one level up to
      avoid single 'harbour' top dir
2013-03-15 11:13:30 +01:00

42 lines
1.0 KiB
Plaintext

/*
* $Id$
*/
/* RFC4648 test vectors for base64 */
#include "simpleio.ch"
PROCEDURE Main()
LOCAL cVector, cStr
LOCAL hTestVectors := { ;
"" => "", ;
"f" => "Zg==", ;
"fo" => "Zm8=", ;
"foo" => "Zm9v", ;
"foob" => "Zm9vYg==", ;
"fooba" => "Zm9vYmE=", ;
"foobar" => "Zm9vYmFy" }
FOR EACH cVector IN hTestVectors
cStr := hb_base64Encode( cVector:__enumKey )
IF !( cStr == cVector )
? hb_StrFormat( "hb_base64Encode(): expected '%s' got '%s' while encoding '%s'", ;
cVector:__enumKey(), cStr, cVector )
ELSE
? hb_StrFormat( "hb_base64Encode(): passed '%s'", cVector:__enumKey )
ENDIF
cStr := hb_base64Decode( cVector )
IF !( cStr == cVector:__enumKey() )
? hb_StrFormat( "hb_base64Decode(): expected '%s' got '%s' while decoding '%s'", ;
cVector, cStr, cVector:__enumKey() )
ELSE
? hb_StrFormat( "hb_base64Decode(): passed '%s'", cVector )
ENDIF
NEXT
RETURN