diff --git a/crates/algorithms/algorithms-c/.clangd b/crates/algorithms/algorithms-c/.clangd new file mode 100644 index 0000000..e719e27 --- /dev/null +++ b/crates/algorithms/algorithms-c/.clangd @@ -0,0 +1,5 @@ +SemanticTokens: + DisabledKinds: [InactiveCode] +CompileFlags: # Tweak the parse settings, example directory given to show format + Add: + - "-Wall" diff --git a/crates/algorithms/algorithms-c/compile_flags.txt b/crates/algorithms/algorithms-c/compile_flags.txt new file mode 100644 index 0000000..8acf612 --- /dev/null +++ b/crates/algorithms/algorithms-c/compile_flags.txt @@ -0,0 +1,10 @@ +-I +./build/vendor/unity/src/ +-I +./build/vendor/cmock/src/ +-I +./src/crc/ +-I +./src/hash/ +-I +./src/ diff --git a/crates/algorithms/algorithms-c/test/crc/crc_common.c b/crates/algorithms/algorithms-c/test/crc/crc_common.c new file mode 100644 index 0000000..c01fba0 --- /dev/null +++ b/crates/algorithms/algorithms-c/test/crc/crc_common.c @@ -0,0 +1,2 @@ +#include "crc_common.h" +const char CRC_CHECK_DATA[CRC_CHECK_DATA_LEN] = {"123456789"}; diff --git a/crates/algorithms/algorithms-c/test/crc/crc_common.h b/crates/algorithms/algorithms-c/test/crc/crc_common.h new file mode 100644 index 0000000..fa80328 --- /dev/null +++ b/crates/algorithms/algorithms-c/test/crc/crc_common.h @@ -0,0 +1,7 @@ +#ifndef CRC_COMMON_H +#define CRC_COMMON_H + +#define CRC_CHECK_DATA_LEN 9 +extern const char CRC_CHECK_DATA[CRC_CHECK_DATA_LEN]; + +#endif // !CRC_COMMON_H diff --git a/crates/algorithms/algorithms-c/test/crc/test_crc.c b/crates/algorithms/algorithms-c/test/crc/test_crc.c index 1e662c1..0371fb6 100755 --- a/crates/algorithms/algorithms-c/test/crc/test_crc.c +++ b/crates/algorithms/algorithms-c/test/crc/test_crc.c @@ -1,21 +1,11 @@ - -#ifdef TEST - #include "unity.h" #include "crc.h" -void setUp(void) -{ -} +void setUp(void) {} -void tearDown(void) -{ -} +void tearDown(void) {} -void test_crc_NeedToImplement(void) -{ - TEST_IGNORE_MESSAGE("Need to Implement crc"); +void test_crc_NeedToImplement(void) { + TEST_IGNORE_MESSAGE("Need to Implement crc"); } - -#endif // TEST diff --git a/crates/algorithms/algorithms-c/test/crc/test_crc32.c b/crates/algorithms/algorithms-c/test/crc/test_crc32.c index bbdb14a..692f109 100755 --- a/crates/algorithms/algorithms-c/test/crc/test_crc32.c +++ b/crates/algorithms/algorithms-c/test/crc/test_crc32.c @@ -1,21 +1,13 @@ - -#ifdef TEST - +#include "crc_common.h" #include "unity.h" #include "crc32.h" -void setUp(void) -{ -} +void setUp(void) {} -void tearDown(void) -{ -} +void tearDown(void) {} -void test_crc32_NeedToImplement(void) -{ - TEST_IGNORE_MESSAGE("Need to Implement crc32"); +void test_crc32_check(void) { + TEST_ASSERT_EQUAL_INT(crc32_checksum(CRC_CHECK_DATA, CRC_CHECK_DATA_LEN), + 0xCBF43926); } - -#endif // TEST diff --git a/crates/algorithms/algorithms-c/test/hash/test_hash.c b/crates/algorithms/algorithms-c/test/hash/test_hash.c index 76ae3c4..106325a 100755 --- a/crates/algorithms/algorithms-c/test/hash/test_hash.c +++ b/crates/algorithms/algorithms-c/test/hash/test_hash.c @@ -1,21 +1,11 @@ - -#ifdef TEST - #include "unity.h" #include "hash.h" -void setUp(void) -{ -} +void setUp(void) {} -void tearDown(void) -{ -} +void tearDown(void) {} -void test_hash_NeedToImplement(void) -{ - TEST_IGNORE_MESSAGE("Need to Implement hash"); +void test_hash_NeedToImplement(void) { + TEST_IGNORE_MESSAGE("Need to Implement hash"); } - -#endif // TEST