File: test_xbase64.cpp

package info (click to toggle)
xtl 0.7.2-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,352 kB
  • sloc: cpp: 19,501; makefile: 164; python: 25
file content (40 lines) | stat: -rw-r--r-- 1,462 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/***************************************************************************
* Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht          *
* Copyright (c) QuantStack                                                 *
*                                                                          *
* Distributed under the terms of the BSD 3-Clause License.                 *
*                                                                          *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#include "xtl/xbase64.hpp"

#include <complex>

#include "gtest/gtest.h"

namespace xtl
{
    TEST(xbase64, encode)
    {
       EXPECT_EQ(base64encode(""), "");
       EXPECT_EQ(base64encode("f"), "Zg==");
       EXPECT_EQ(base64encode("fo"), "Zm8=");
       EXPECT_EQ(base64encode("foo"), "Zm9v");
       EXPECT_EQ(base64encode("foob"), "Zm9vYg==");
       EXPECT_EQ(base64encode("fooba"), "Zm9vYmE=");
       EXPECT_EQ(base64encode("foobar"), "Zm9vYmFy");
    }

    TEST(xbase64, decode)
    {
       EXPECT_EQ(base64decode(""), "");
       EXPECT_EQ(base64decode("Zg=="), "f");
       EXPECT_EQ(base64decode("Zm8="), "fo");
       EXPECT_EQ(base64decode("Zm9v"), "foo");
       EXPECT_EQ(base64decode("Zm9vYg=="), "foob");
       EXPECT_EQ(base64decode("Zm9vYmE="), "fooba");
       EXPECT_EQ(base64decode("Zm9vYmFy"), "foobar");
    }
}