1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include "pch.h"
- #include "CppUnitTest.h"
- #include <Base64.h>
- #include <Text.h>
- using namespace Microsoft::VisualStudio::CppUnitTestFramework;
- // test class for base64 encoding and decoding
- namespace FrameworkTests
- {
- TEST_CLASS(Base64Tests)
- {
- public:
- TEST_METHOD(TestEncoding)
- {
- const char* data = "Hello World!";
- const char* encoded = "SGVsbG8gV29ybGQh";
- Framework::Text encodedData = Framework::base64Encode(data, Framework::textLength(data));
- Assert::AreEqual(encoded, encodedData.getText());
- }
-
- TEST_METHOD(TestDecoding)
- {
- const char* data = "SGVsbG8gV29ybGQh";
- const char* decoded = "Hello World!";
- char* decodedData = 0;
- int decodecLength;
- Framework::base64Decode(data, &decodedData, &decodecLength);
- Assert::AreEqual(decoded, decodedData);
- delete[] decodedData;
- }
- TEST_METHOD(TestDecodingInvalid)
- {
- const char* data = "SGVsbG8.gVd29ybGQh";
- char* decodedData = 0;
- int decodecLength;
- Framework::base64Decode(data, &decodedData, &decodecLength);
- Assert::AreEqual(0, decodecLength);
- delete[] decodedData;
- }
- };
- }
|