2019-02-07 23:22:40 +02:00
|
|
|
#include <unistd.h>
|
2019-01-19 18:16:00 +02:00
|
|
|
#include "tests.h"
|
|
|
|
#include "tests_macros.h"
|
|
|
|
#include "ft_base64.h"
|
|
|
|
|
|
|
|
TEST_RESULT should_init_base64_ctx(TEST_PARAMS, TEST_DATA)
|
|
|
|
{
|
|
|
|
UNUSED(test_params);
|
|
|
|
UNUSED(test_data);
|
|
|
|
t_base64_ctx ctx;
|
2019-02-02 19:13:36 +02:00
|
|
|
char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\
|
|
|
|
abcdefghijklmnopqrstuvwxyz0123456789+/";
|
2019-01-19 18:16:00 +02:00
|
|
|
|
|
|
|
ft_base64_init(&ctx);
|
|
|
|
|
2019-02-07 23:22:40 +02:00
|
|
|
munit_assert_true(ctx.input_fd == STDIN_FILENO);
|
|
|
|
munit_assert_true(ctx.output_fd == STDOUT_FILENO);
|
|
|
|
|
2019-01-29 23:23:04 +02:00
|
|
|
munit_assert_string_equal(alphabet, (char *)ctx.alphabet);
|
|
|
|
|
|
|
|
return MUNIT_OK;
|
|
|
|
}
|
|
|
|
|
2019-02-07 23:22:40 +02:00
|
|
|
TEST_RESULT should_transform_base64_block(TEST_PARAMS, TEST_DATA)
|
2019-01-29 23:23:04 +02:00
|
|
|
{
|
|
|
|
UNUSED(test_params);
|
|
|
|
UNUSED(test_data);
|
|
|
|
|
|
|
|
t_base64_ctx ctx;
|
2019-02-23 23:56:27 +02:00
|
|
|
t_byte1 buff[FT_BASE64_DECODE_BLOCK_SIZE];
|
2019-01-29 23:23:04 +02:00
|
|
|
|
|
|
|
ft_base64_init(&ctx);
|
|
|
|
|
2019-02-23 23:56:27 +02:00
|
|
|
ft_base64_encode_transform(&ctx, (t_byte1 *)"Man", buff);
|
|
|
|
munit_assert_string_equal((char *)buff, "TWFu");
|
2019-01-29 23:23:04 +02:00
|
|
|
|
2019-02-23 23:56:27 +02:00
|
|
|
ft_base64_encode_transform(&ctx, (t_byte1 *)"LOL", buff);
|
|
|
|
munit_assert_string_equal((char *)buff, "TE9M");
|
2019-01-19 18:16:00 +02:00
|
|
|
return MUNIT_OK;
|
|
|
|
}
|