From 814dd940b0e5cb5006a624ca9b61eb7ace28c504 Mon Sep 17 00:00:00 2001 From: Gregory Date: Tue, 23 Oct 2018 21:07:38 +0300 Subject: [PATCH] some tests format according to norm --- t/md5_tests.c | 78 +++++++++++++++++++++++++++++---------------------- t/sha_tests.c | 14 ++++++++- t/tests.c | 53 +++++++++++++++++----------------- 3 files changed, 84 insertions(+), 61 deletions(-) diff --git a/t/md5_tests.c b/t/md5_tests.c index 37ebf0e1..8b9989c0 100644 --- a/t/md5_tests.c +++ b/t/md5_tests.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* md5_tests.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: gtertysh +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/10/23 21:06:22 by gtertysh #+# #+# */ +/* Updated: 2018/10/23 21:06:33 by gtertysh ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "tests.h" #include "tests_macros.h" #include "ft_md5.h" @@ -5,59 +17,59 @@ TEST_RESULT should_init_ctx(TEST_PARAMS, TEST_DATA) { - UNUSED(test_params); - UNUSED(test_data); - t_md5_ctx ctx; + UNUSED(test_params); + UNUSED(test_data); + t_md5_ctx ctx; - ft_md5_init(&ctx); + ft_md5_init(&ctx); munit_assert_uint(ctx.a, ==, 0x67452301); munit_assert_uint(ctx.b, ==, 0xefcdab89); - munit_assert_uint(ctx.c, ==, 0x98badcfe); - munit_assert_uint(ctx.d, ==, 0x10325476); - munit_assert_true(ctx.bit_len == 0); - for (int i = 0; i < 64; i++) - munit_assert_uchar(ctx.block[i], ==, 0); + munit_assert_uint(ctx.c, ==, 0x98badcfe); + munit_assert_uint(ctx.d, ==, 0x10325476); + munit_assert_true(ctx.bit_len == 0); + for (int i = 0; i < 64; i++) + munit_assert_uchar(ctx.block[i], ==, 0); - return MUNIT_OK; + return MUNIT_OK; } TEST_RESULT decode_string_to_int(TEST_PARAMS, TEST_DATA) { - UNUSED(test_params); - UNUSED(test_data); + UNUSED(test_params); + UNUSED(test_data); - t_byte1 block[FT_MD5_BLOCK_SIZE]; - t_byte4 words[FT_MD5_WORDS_COUNT]; + t_byte1 block[FT_MD5_BLOCK_SIZE]; + t_byte4 words[FT_MD5_WORDS_COUNT]; - ft_bzero(block, FT_MD5_BLOCK_SIZE); - block[0] = 'a'; - block[9] = 'b'; - block[63] = 'c'; + ft_bzero(block, FT_MD5_BLOCK_SIZE); + block[0] = 'a'; + block[9] = 'b'; + block[63] = 'c'; - ft_md5_decode(words, block); + ft_md5_decode(words, block); - munit_assert_true((words[0] & 0xff) == 97); - munit_assert_true(((words[2] >> 8) & 0xff) == 98); - munit_assert_true(((words[15] >> 24) & 0xff) == 99); + munit_assert_true((words[0] & 0xff) == 97); + munit_assert_true(((words[2] >> 8) & 0xff) == 98); + munit_assert_true(((words[15] >> 24) & 0xff) == 99); - return MUNIT_OK; + return MUNIT_OK; } TEST_RESULT update_should_change_count(TEST_PARAMS, TEST_DATA) { - UNUSED(test_params); - UNUSED(test_data); - t_md5_ctx ctx; - char message[] = "hello, World!"; - t_byte8 size = ft_strlen(message); + UNUSED(test_params); + UNUSED(test_data); + t_md5_ctx ctx; + char message[] = "hello, World!"; + t_byte8 size = ft_strlen(message); - ft_md5_init(&ctx); - ft_md5_update(&ctx, (t_byte1 *)message, size); + ft_md5_init(&ctx); + ft_md5_update(&ctx, (t_byte1 *)message, size); - munit_assert_true(size * 8 == ctx.bit_len); + munit_assert_true(size * 8 == ctx.bit_len); - return MUNIT_OK; + return MUNIT_OK; } TEST_RESULT encode_bits_to_string(TEST_PARAMS, TEST_DATA) @@ -184,4 +196,4 @@ TEST_RESULT create_string(TEST_PARAMS, TEST_DATA) munit_assert_string_equal((const char *)digest_string, "d41d8cd98f00b204e9800998ecf8427e"); return MUNIT_OK; -} \ No newline at end of file +} diff --git a/t/sha_tests.c b/t/sha_tests.c index 03630ea6..d840d3a0 100644 --- a/t/sha_tests.c +++ b/t/sha_tests.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* sha_tests.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: gtertysh +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/10/23 21:06:43 by gtertysh #+# #+# */ +/* Updated: 2018/10/23 21:06:44 by gtertysh ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "tests.h" #include "tests_macros.h" #include "ft_sha.h" @@ -283,4 +295,4 @@ TEST_RESULT create_digest_string_sha224(TEST_PARAMS, TEST_DATA) (const char *)digest_string); return MUNIT_OK; -} \ No newline at end of file +} diff --git a/t/tests.c b/t/tests.c index 9a04727e..ebdc72c2 100644 --- a/t/tests.c +++ b/t/tests.c @@ -1,8 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* tests.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: gtertysh +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2018/10/23 21:00:24 by gtertysh #+# #+# */ +/* Updated: 2018/10/23 21:05:47 by gtertysh ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "tests.h" #include "tests_macros.h" - -MunitTest md5_tests[] = { +MunitTest g_md5_tests[] = { IT("/init_ctx", should_init_ctx, NULL, NULL, 0, NULL), IT("/updates_ctx_count", update_should_change_count, NULL, NULL, 0, NULL), IT("/decode_string_to_int", decode_string_to_int, NULL, NULL, 0, NULL), @@ -13,7 +24,7 @@ MunitTest md5_tests[] = { END_IT }; -MunitTest sha_tests[] = { +MunitTest g_sha_tests[] = { IT("/init_ctx_256", should_init_ctx_sha256, NULL, NULL, 0, NULL), IT("/init_ctx_224", should_init_ctx_sha224, NULL, NULL, 0, NULL), IT("/decode_string", decode_string_to_int_sha256, NULL, NULL, 0, NULL), @@ -28,33 +39,21 @@ MunitTest sha_tests[] = { IT("/creates_string_224", create_digest_string_sha224, NULL, NULL, 0, NULL), END_IT}; -static const MunitSuite ft_ssl_suites[] = { - { - (char *)"/md5_suite", /* name */ - md5_tests, /* tests */ - NULL, /* suites */ - 1, /* iterations */ - MUNIT_SUITE_OPTION_NONE /* options */ - }, - { - (char *)"/sha_suite", /* name */ - sha_tests, /* tests */ - NULL, /* suites */ - 1, /* iterations */ - MUNIT_SUITE_OPTION_NONE /* options */ - }, +static const MunitSuite g_ft_ssl_suites[] = { + {(char *)"/md5_suite", g_md5_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE}, + {(char *)"/sha_suite", g_sha_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE}, {NULL, NULL, NULL, 0, MUNIT_SUITE_OPTION_NONE} }; -static const MunitSuite main_suite = { - (char *)"/ft_ssl", /* name */ - NULL, /* tests */ - (MunitSuite *)ft_ssl_suites, /* suites */ - 1, /* iterations */ - MUNIT_SUITE_OPTION_NONE /* options */ +static const MunitSuite g_main_suite = { + (char *)"/ft_ssl", + NULL, + (MunitSuite *)g_ft_ssl_suites, + 1, + MUNIT_SUITE_OPTION_NONE }; -int main(int argc, char **argv) +int main(int argc, char **argv) { - return munit_suite_main(&main_suite, NULL, argc, argv); -} \ No newline at end of file + return (munit_suite_main(&g_main_suite, NULL, argc, argv)); +}