llbase64_tut.cpp

Go to the documentation of this file.
00001 
00033 #include "linden_common.h"
00034 #include "lltut.h"
00035 
00036 #include "llbase64.h"
00037 
00038 #include <string>
00039 #include "lluuid.h"
00040 
00041 namespace tut
00042 {
00043         struct base64_data
00044         {
00045         };
00046         typedef test_group<base64_data> base64_test;
00047         typedef base64_test::object base64_object;
00048         tut::base64_test base64("base64");
00049 
00050         template<> template<>
00051         void base64_object::test<1>()
00052         {
00053                 std::string result;
00054 
00055                 result = LLBase64::encode(NULL, 0);
00056                 ensure("encode nothing", (result == "") );
00057 
00058                 LLUUID nothing;
00059                 result = LLBase64::encode(&nothing.mData[0], UUID_BYTES);
00060                 ensure("encode blank uuid",
00061                                 (result == "AAAAAAAAAAAAAAAAAAAAAA==") );
00062 
00063                 LLUUID id("526a1e07-a19d-baed-84c4-ff08a488d15e");
00064                 result = LLBase64::encode(&id.mData[0], UUID_BYTES);
00065                 ensure("encode random uuid",
00066                                 (result == "UmoeB6Gduu2ExP8IpIjRXg==") );
00067 
00068         }
00069 
00070         template<> template<>
00071         void base64_object::test<2>()
00072         {
00073                 std::string result;
00074 
00075                 U8 blob[40] = { 115, 223, 172, 255, 140, 70, 49, 125, 236, 155, 45, 199, 101, 17, 164, 131, 230, 19, 80, 64, 112, 53, 135, 98, 237, 12, 26, 72, 126, 14, 145, 143, 118, 196, 11, 177, 132, 169, 195, 134 };
00076                 result = LLBase64::encode(&blob[0], 40);
00077                 ensure("encode 40 bytes", 
00078                                 (result == "c9+s/4xGMX3smy3HZRGkg+YTUEBwNYdi7QwaSH4OkY92xAuxhKnDhg==") );
00079         }
00080 
00081 }

Generated on Thu Jul 1 06:08:19 2010 for Second Life Viewer by  doxygen 1.4.7