diff --git a/test/test.c b/lib/assert.c similarity index 79% rename from test/test.c rename to lib/assert.c index d2b5310..8c3b17e 100644 --- a/test/test.c +++ b/lib/assert.c @@ -1,7 +1,7 @@ -#include "test.h" +#include "assert.h" bool assert_string_equal(const string_t actual, const string_t expected) { - if (strcmp(expected, actual) != 0) { + if (!string_equals(actual, expected)) { printf("FAIL: expected = \"%s\" ; actual = \"%s\"\n", expected, actual); return false; } @@ -9,7 +9,7 @@ bool assert_string_equal(const string_t actual, const string_t expected) { } bool assert_string_not_equal(const string_t actual, const string_t expected) { - if (strcmp(expected, actual) == 0) { + if (string_equals(actual, expected)) { printf("FAIL: expected = \"%s\" ; actual = \"%s\"\n", expected, actual); return false; } diff --git a/lib/assert.h b/lib/assert.h new file mode 100644 index 0000000..871a41f --- /dev/null +++ b/lib/assert.h @@ -0,0 +1,30 @@ +#ifndef __LIBCPROJECT_ASSERT__ +#define __LIBCPROJECT_ASSERT__ + +#include +#include +#include +#include + +#include "string.h" +#include "types.h" + +/** + * @brief Check if the two strings are equal. If they are not equal, print the expected and actual strings. + * + * @param character + * @return bool + * @since v5.0.0 + */ +bool assert_string_equal(const string_t actual, const string_t expected); + +/** + * @brief Check if the two strings are not equal. If they are equal, print the expected and actual strings. + * + * @param character + * @return bool + * @since v5.0.0 + */ +bool assert_string_not_equal(const string_t actual, const string_t expected); + +#endif diff --git a/lib/character.h b/lib/character.h index f1f7374..724f624 100644 --- a/lib/character.h +++ b/lib/character.h @@ -48,8 +48,7 @@ char character_to_lower(const char character); * @brief Check if the character is a digit ('0', '1', '2', '3', '4', '5', '6', '7, '8' or '9'). * * @param character - * @return true - * @return false + * @return bool * @since v1.0.0 */ bool character_get_is_digit(const char character); diff --git a/lib/filesystem.h b/lib/filesystem.h index 2ebe051..ea0098f 100644 --- a/lib/filesystem.h +++ b/lib/filesystem.h @@ -43,8 +43,7 @@ int filesystem_write(string_t path, byte_t *file_content, size_t file_size); * @brief Check if a path exists. * * @param path - * @return true - * @return false + * @return bool * @since v3.1.0 */ bool filesystem_exists(string_t path); diff --git a/lib/hash_map.h b/lib/hash_map.h index cc4b086..e9df556 100644 --- a/lib/hash_map.h +++ b/lib/hash_map.h @@ -85,8 +85,7 @@ void *hash_map_get(struct hash_map *hash_map, string_t key); * * @param hash_map * @param key - * @return true - * @return false + * @return bool * @since v2.0.0 */ bool hash_map_contains_key(struct hash_map *hash_map, string_t key); diff --git a/lib/mathematics.h b/lib/mathematics.h index 2d693df..fc1e0f5 100644 --- a/lib/mathematics.h +++ b/lib/mathematics.h @@ -14,8 +14,7 @@ * * @param number1 * @param number2 - * @return true - * @return false + * @return bool * @since v1.0.0 */ bool mathematics_equals(const float64_t number1, const float64_t number2); diff --git a/libcproject.h b/libcproject.h index 844de1b..8554757 100644 --- a/libcproject.h +++ b/libcproject.h @@ -2,6 +2,7 @@ #define __LIBCPROJECT__ #include "lib/array_list.h" +#include "lib/assert.h" #include "lib/character.h" #include "lib/convert.h" #include "lib/date.h" diff --git a/test/character_test.h b/test/character_test.h index 2a02770..9e18685 100644 --- a/test/character_test.h +++ b/test/character_test.h @@ -6,7 +6,6 @@ #include #include "libcproject.h" -#include "test.h" void character_test(); diff --git a/test/convert_test.h b/test/convert_test.h index 8eb6889..8e9c0ff 100644 --- a/test/convert_test.h +++ b/test/convert_test.h @@ -6,7 +6,6 @@ #include #include "libcproject.h" -#include "test.h" void convert_test(); diff --git a/test/date_test.h b/test/date_test.h index 3d9ddaf..d3ec9b7 100644 --- a/test/date_test.h +++ b/test/date_test.h @@ -4,7 +4,6 @@ #include #include "libcproject.h" -#include "test.h" void date_test(); diff --git a/test/string_test.h b/test/string_test.h index bcef767..70a547a 100644 --- a/test/string_test.h +++ b/test/string_test.h @@ -6,7 +6,6 @@ #include #include "libcproject.h" -#include "test.h" void string_test(); diff --git a/test/test.h b/test/test.h deleted file mode 100644 index 50c9fa8..0000000 --- a/test/test.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __TEST__ -#define __TEST__ - -#include -#include -#include - -#include "libcproject.h" - -bool assert_string_equal(const string_t actual, const string_t expected); - -bool assert_string_not_equal(const string_t actual, const string_t expected); - -#endif