mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
Apply suggestions from code review
Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
parent
f8e43ac88f
commit
597dc1972b
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file run_length_encoding.c
|
* @file
|
||||||
* @author [serturx](https://github.com/serturx/)
|
* @author [serturx](https://github.com/serturx/)
|
||||||
* @brief Encode a null terminated string using [Run-length encoding](https://en.wikipedia.org/wiki/Run-length_encoding)
|
* @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;
|
return compacted_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void test() {
|
/**
|
||||||
|
* @brief Self-test implementations
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
static void test() {
|
||||||
char* test;
|
char* test;
|
||||||
test = run_length_encode("aaaaaaabbbaaccccdefaadr");
|
test = run_length_encode("aaaaaaabbbaaccccdefaadr");
|
||||||
assert(!strcmp(test, "7a3b2a4c1d1e1f2a1d1r"));
|
assert(!strcmp(test, "7a3b2a4c1d1e1f2a1d1r"));
|
||||||
@ -68,8 +72,12 @@ void test() {
|
|||||||
free(test);
|
free(test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Main function
|
||||||
|
* @returns 0 on exit
|
||||||
|
*/
|
||||||
int main() {
|
int main() {
|
||||||
test();
|
test(); // run self-test implementations
|
||||||
printf("Tests passed.");
|
printf("All tests have passed!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user