From 597dc1972b6e8562dbb01e9caf1162de89f89964 Mon Sep 17 00:00:00 2001 From: serturx <56551721+serturx@users.noreply.github.com> Date: Mon, 3 Oct 2022 10:23:38 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: David Leal --- misc/run_length_encoding.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/misc/run_length_encoding.c b/misc/run_length_encoding.c index ff82667f..9857f499 100644 --- a/misc/run_length_encoding.c +++ b/misc/run_length_encoding.c @@ -1,5 +1,5 @@ /** - * @file run_length_encoding.c + * @file * @author [serturx](https://github.com/serturx/) * @brief Encode a null terminated string using [Run-length encoding](https://en.wikipedia.org/wiki/Run-length_encoding) */ @@ -55,7 +55,11 @@ char* run_length_encode(char* str) { return compacted_string; } -void test() { +/** + * @brief Self-test implementations + * @returns void + */ +static void test() { char* test; test = run_length_encode("aaaaaaabbbaaccccdefaadr"); assert(!strcmp(test, "7a3b2a4c1d1e1f2a1d1r")); @@ -68,8 +72,12 @@ void test() { free(test); } +/** + * @brief Main function + * @returns 0 on exit + */ int main() { - test(); - printf("Tests passed."); + test(); // run self-test implementations + printf("All tests have passed!\n"); return 0; -} \ No newline at end of file +}