base64_test.cpp

来自「Jabber code library, developed with c」· C++ 代码 · 共 57 行

CPP
57
字号
#include "../../base64.h"using namespace gloox;#include <stdio.h>#include <locale.h>#include <string>int main( int /*argc*/, char** /*argv*/ ){  int fail = 0;  std::string name;  std::string b;  std::string sample;  // -------  name = "empty string";  sample = "";  b = Base64::encode64( sample );  if( sample != Base64::decode64( b ) )  {    ++fail;    printf( "test '%s' failed\n", name.c_str() );  }  b = "";  sample = "";  // -------  name = "leviathan test";  sample = "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.";  b = Base64::encode64( sample );  if( sample != Base64::decode64( b ) )  {    ++fail;    printf( "test '%s' failed: %s\n", name.c_str(), b.c_str() );  }  b = "";  sample = "";  if( fail == 0 )  {    printf( "Base64: all tests passed\n" );    return 0;  }  else  {    printf( "Base64: %d test(s) failed\n", fail );    return 1;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?