VirtualBox

Ignore:
Timestamp:
Feb 14, 2009 9:32:04 AM (16 years ago)
Author:
vboxsync
Message:

Wrote RTBase64Encode while at it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstBase64.cpp

    r16765 r16766  
    3838#include <iprt/initterm.h>
    3939
     40/*******************************************************************************
     41*   Defined Constants And Macros                                               *
     42*******************************************************************************/
     43#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
     44# define MY_NL "\r\n"
     45#else
     46# define MY_NL "\n"
     47#endif
     48
    4049
    4150int main()
     
    6170        TEST_ENTRY("Hey", "SGV5"),
    6271        TEST_ENTRY("Base64", "QmFzZTY0"),
    63         TEST_ENTRY("Call me Ishmael.", "Q2FsbCBtZSBJc2htYWVsLg==")
     72        TEST_ENTRY("Call me Ishmael.", "Q2FsbCBtZSBJc2htYWVsLg=="),
     73        TEST_ENTRY(
     74        "Man is distinguished, not only by his reason, but by this singular passion "
     75        "from other animals, which is a lust of the mind, that by a perseverance of "
     76        "delight in the continued and indefatigable generation of knowledge, exceeds "
     77        "the short vehemence of any carnal pleasure." /* Thomas Hobbes's Leviathan */,
     78        "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1" MY_NL
     79        "dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3" MY_NL
     80        "aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFu" MY_NL
     81        "Y2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxl" MY_NL
     82        "IGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhl" MY_NL
     83        "bWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4="
     84        )
    6485#undef TEST_ENTRY
    6586    };
     
    94115        }
    95116
    96         rc = RTBase64Encode(g_aTests[i].pszText, g_aTests[i].cchText, szOut, g_aTests[i].cchEnc + 1, &cchOut);
     117        rc = RTBase64Encode(g_aTests[i].pszText, g_aTests[i].cchText, szOut, g_aTests[i].cchEnc*2 + 1, &cchOut);
    97118        if (RT_FAILURE(rc))
    98119        {
     
    124145
    125146    /*
    126      * Bigger Test.
     147     * Try with some more junk in the encoding and different line length.
    127148     */
    128149    static const char s_szText2[] =
     
    133154
    134155    static const char s_szEnc2[] =
    135         " TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz\n"
    136         " IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg\n\r"
    137         " dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu\n"
    138         " dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo\n\r"
    139         " ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=\n \n";
     156        "  TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz\r\n"
     157        "  IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg\n\r\t\t\t\v"
     158          "dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu\n"
     159        "\tdWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo\n\r"
     160        "  ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=\n \n   \r   \n \t";
    140161
    141162    int rc = RTBase64Decode(&s_szEnc2[0], szOut, sizeof(s_szText2), &cchOut, NULL);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette