diff options
Diffstat (limited to 'test/Base64Test.cc')
| -rw-r--r-- | test/Base64Test.cc | 171 |
1 files changed, 100 insertions, 71 deletions
diff --git a/test/Base64Test.cc b/test/Base64Test.cc index f0080099..88acc1ea 100644 --- a/test/Base64Test.cc +++ b/test/Base64Test.cc @@ -3,28 +3,27 @@ namespace aria2 { -class Base64Test:public CppUnit::TestFixture { +class Base64Test : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(Base64Test); CPPUNIT_TEST(testEncode); CPPUNIT_TEST(testDecode); CPPUNIT_TEST(testLongString); CPPUNIT_TEST_SUITE_END(); -private: +private: public: - void setUp() { - } + void setUp() {} void testEncode(); void testDecode(); void testLongString(); }; +CPPUNIT_TEST_SUITE_REGISTRATION(Base64Test); -CPPUNIT_TEST_SUITE_REGISTRATION( Base64Test ); - -void Base64Test::testEncode() { +void Base64Test::testEncode() +{ std::string s = "Hello World!"; CPPUNIT_ASSERT_EQUAL(std::string("SGVsbG8gV29ybGQh"), base64::encode(s.begin(), s.end())); @@ -98,71 +97,101 @@ void Base64Test::testDecode() void Base64Test::testLongString() { - std::string s = - "LyogPCEtLSBjb3B5cmlnaHQgKi8KLyoKICogYXJpYTIgLSBUaGUgaGlnaCBzcGVlZCBkb3dubG9h" - "ZCB1dGlsaXR5CiAqCiAqIENvcHlyaWdodCAoQykgMjAwNiBUYXRzdWhpcm8gVHN1amlrYXdhCiAq" - "CiAqIFRoaXMgcHJvZ3JhbSBpcyBmcmVlIHNvZnR3YXJlOyB5b3UgY2FuIHJlZGlzdHJpYnV0ZSBp" - "dCBhbmQvb3IgbW9kaWZ5CiAqIGl0IHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgR05VIEdlbmVyYWwg" - "UHVibGljIExpY2Vuc2UgYXMgcHVibGlzaGVkIGJ5CiAqIHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5k" - "YXRpb247IGVpdGhlciB2ZXJzaW9uIDIgb2YgdGhlIExpY2Vuc2UsIG9yCiAqIChhdCB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ogKiBPcGVuU1NMIGxpYnJhcnkgdW5kZXIgY2VydGFpbiBjb25kaXRpb25z" + "IGFzIGRlc2NyaWJl" + "ZCBpbiBlYWNoCiAqIGluZGl2aWR1YWwgc291cmNlIGZpbGUsIGFuZCBkaXN0" + "cmlidXRlIGxpbmtl" + "ZCBjb21iaW5hdGlvbnMKICogaW5jbHVkaW5nIHRoZSB0d28uCiAqIFlvdSBt" + "dXN0IG9iZXkgdGhl" + "IEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlIGluIGFsbCByZXNwZWN0cwog" + "KiBmb3IgYWxsIG9m" + "IHRoZSBjb2RlIHVzZWQgb3RoZXIgdGhhbiBPcGVuU1NMLiAgSWYgeW91IG1v" + "ZGlmeQogKiBmaWxl" + "KHMpIHdpdGggdGhpcyBleGNlcHRpb24sIHlvdSBtYXkgZXh0ZW5kIHRoaXMg" + "ZXhjZXB0aW9uIHRv" + "IHlvdXIKICogdmVyc2lvbiBvZiB0aGUgZmlsZShzKSwgYnV0IHlvdSBhcmUg" + "bm90IG9ibGlnYXRl" + "ZCB0byBkbyBzby4gIElmIHlvdQogKiBkbyBub3Qgd2lzaCB0byBkbyBzbywg" + "ZGVsZXRlIHRoaXMg" + "ZXhjZXB0aW9uIHN0YXRlbWVudCBmcm9tIHlvdXIKICogdmVyc2lvbi4gIElm" + "IHlvdSBkZWxldGUg" + "dGhpcyBleGNlcHRpb24gc3RhdGVtZW50IGZyb20gYWxsIHNvdXJjZQogKiBm" + "aWxlcyBpbiB0aGUg" + "cHJvZ3JhbSwgdGhlbiBhbHNvIGRlbGV0ZSBpdCBoZXJlLgogKi8KLyogY29w" + "eXJpZ2h0IC0tPiAq" + "Lwo="; std::string d = - "/* <!-- copyright */\n" - "/*\n" - " * aria2 - The high speed download utility\n" - " *\n" - " * Copyright (C) 2006 Tatsuhiro Tsujikawa\n" - " *\n" - " * This program is free software; you can redistribute it and/or modify\n" - " * it under the terms of the GNU General Public License as published by\n" - " * the Free Software Foundation; either version 2 of the License, or\n" - " * (at your option) any later version.\n" - " *\n" - " * This program is distributed in the hope that it will be useful,\n" - " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - " * GNU General Public License for more details.\n" - " *\n" - " * You should have received a copy of the GNU General Public License\n" - " * along with this program; if not, write to the Free Software\n" - " * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n" - " *\n" - " * In addition, as a special exception, the copyright holders give\n" - " * permission to link the code of portions of this program with the\n" - " * OpenSSL library under certain conditions as described in each\n" - " * individual source file, and distribute linked combinations\n" - " * including the two.\n" - " * You must obey the GNU General Public License in all respects\n" - " * for all of the code used other than OpenSSL. If you modify\n" - " * file(s) with this exception, you may extend this exception to your\n" - " * version of the file(s), but you are not obligated to do so. If you\n" - " * do not wish to do so, delete this exception statement from your\n" - " * version. If you delete this exception statement from all source\n" - " * files in the program, then also delete it here.\n" - " */\n" - "/* copyright --> */\n"; + "/* <!-- copyright */\n" + "/*\n" + " * aria2 - The high speed download utility\n" + " *\n" + " * Copyright (C) 2006 Tatsuhiro Tsujikawa\n" + " *\n" + " * This program is free software; you can redistribute it and/or " + "modify\n" + " * it under the terms of the GNU General Public License as published " + "by\n" + " * the Free Software Foundation; either version 2 of the License, or\n" + " * (at your option) any later version.\n" + " *\n" + " * This program is distributed in the hope that it will be useful,\n" + " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + " * GNU General Public License for more details.\n" + " *\n" + " * You should have received a copy of the GNU General Public License\n" + " * along with this program; if not, write to the Free Software\n" + " * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA " + "02110-1301 USA\n" + " *\n" + " * In addition, as a special exception, the copyright holders give\n" + " * permission to link the code of portions of this program with the\n" + " * OpenSSL library under certain conditions as described in each\n" + " * individual source file, and distribute linked combinations\n" + " * including the two.\n" + " * You must obey the GNU General Public License in all respects\n" + " * for all of the code used other than OpenSSL. If you modify\n" + " * file(s) with this exception, you may extend this exception to your\n" + " * version of the file(s), but you are not obligated to do so. If you\n" + " * do not wish to do so, delete this exception statement from your\n" + " * version. If you delete this exception statement from all source\n" + " * files in the program, then also delete it here.\n" + " */\n" + "/* copyright --> */\n"; CPPUNIT_ASSERT_EQUAL(d, base64::decode(s.begin(), s.end())); CPPUNIT_ASSERT_EQUAL(s, base64::encode(d.begin(), d.end())); } |
