Skip to content

Commit

Permalink
MD5 - Rename test cases to better reflect what they're doing
Browse files Browse the repository at this point in the history
  • Loading branch information
gahr authored and flatcap committed Jan 24, 2018
1 parent e24d901 commit 454a262
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
NEOMUTT_TEST_ITEM(test_base64_lengths) \
NEOMUTT_TEST_ITEM(test_rfc2047) \
NEOMUTT_TEST_ITEM(test_md5) \
NEOMUTT_TEST_ITEM(test_md5_bytes) \
NEOMUTT_TEST_ITEM(test_md5_buffer)
NEOMUTT_TEST_ITEM(test_md5_ctx) \
NEOMUTT_TEST_ITEM(test_md5_ctx_bytes)

/******************************************************************************
* You probably don't need to touch what follows.
Expand Down
17 changes: 9 additions & 8 deletions test/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ static const struct
};
/* clang-format on */

void test_md5_bytes(void)
void test_md5(void)
{
for (size_t i = 0; i < mutt_array_size(test_data); ++i)
{
struct Md5Ctx ctx;
unsigned char buf[16];
char digest[33];
mutt_md5_init_ctx(&ctx);
mutt_md5_process_bytes(test_data[i].text, strlen(test_data[i].text), &ctx);
mutt_md5_finish_ctx(&ctx, buf);
mutt_md5(test_data[i].text, buf);
mutt_md5_toascii(buf, digest);
if (!TEST_CHECK(strcmp(test_data[i].hash, digest) == 0))
{
Expand All @@ -42,7 +39,7 @@ void test_md5_bytes(void)
}
}

void test_md5(void)
void test_md5_ctx(void)
{
for (size_t i = 0; i < mutt_array_size(test_data); ++i)
{
Expand All @@ -62,13 +59,16 @@ void test_md5(void)
}
}

void test_md5_buffer(void)
void test_md5_ctx_bytes(void)
{
for (size_t i = 0; i < mutt_array_size(test_data); ++i)
{
struct Md5Ctx ctx;
unsigned char buf[16];
char digest[33];
mutt_md5(test_data[i].text, buf);
mutt_md5_init_ctx(&ctx);
mutt_md5_process_bytes(test_data[i].text, strlen(test_data[i].text), &ctx);
mutt_md5_finish_ctx(&ctx, buf);
mutt_md5_toascii(buf, digest);
if (!TEST_CHECK(strcmp(test_data[i].hash, digest) == 0))
{
Expand All @@ -78,3 +78,4 @@ void test_md5_buffer(void)
}
}
}

0 comments on commit 454a262

Please sign in to comment.