diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b6db61..b4391be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,12 +6,12 @@ set(CMAKE_C_STANDARD 99) include_directories(include) set(SOURCES - src/linkedlist.c - src/set.c - src/stack.c - src/binarytree.c - src/input.c - src/math.c + src/lflinkedlist.c + src/lfset.c + src/lfstack.c + src/lfbinarytree.c + src/lfinput.c + src/lfmath.c ) add_library(flint ${SOURCES}) diff --git a/include/binarytree.h b/include/lfbinarytree.h similarity index 100% rename from include/binarytree.h rename to include/lfbinarytree.h diff --git a/include/input.h b/include/lfinput.h similarity index 100% rename from include/input.h rename to include/lfinput.h diff --git a/include/linkedlist.h b/include/lflinkedlist.h similarity index 100% rename from include/linkedlist.h rename to include/lflinkedlist.h diff --git a/include/math.h b/include/lfmath.h similarity index 100% rename from include/math.h rename to include/lfmath.h diff --git a/include/set.h b/include/lfset.h similarity index 95% rename from include/set.h rename to include/lfset.h index 1589f6a..75636f3 100644 --- a/include/set.h +++ b/include/lfset.h @@ -1,7 +1,7 @@ #ifndef LIBFLINT_SET_H #define LIBFLINT_SET_H -#include "linkedlist.h" +#include "lflinkedlist.h" #define Set List diff --git a/include/stack.h b/include/lfstack.h similarity index 91% rename from include/stack.h rename to include/lfstack.h index 5457afb..59894b3 100644 --- a/include/stack.h +++ b/include/lfstack.h @@ -1,7 +1,7 @@ #ifndef LIBFLINT_STACK_H #define LIBFLINT_STACK_H -#include "linkedlist.h" +#include "lflinkedlist.h" #define Stack List diff --git a/src/binarytree.c b/src/lfbinarytree.c similarity index 99% rename from src/binarytree.c rename to src/lfbinarytree.c index e9fe047..e0a7035 100644 --- a/src/binarytree.c +++ b/src/lfbinarytree.c @@ -2,7 +2,7 @@ #include #include -#include "binarytree.h" +#include "lfbinarytree.h" void bintree_init(BinTree *tree, void (*destroy)(void *data)) { tree->size = 0; diff --git a/src/input.c b/src/lfinput.c similarity index 95% rename from src/input.c rename to src/lfinput.c index f892896..3ceb28c 100644 --- a/src/input.c +++ b/src/lfinput.c @@ -7,7 +7,7 @@ #include #endif -#include "input.h" +#include "lfinput.h" char *get_input(const char *path) { FILE *fp = NULL; @@ -67,7 +67,7 @@ int *get_ints(const char *path, size_t *sz) { for (size_t idx = 0; idx < *sz; idx++) { int n; const char *errstr; - n = strtonum(lines[idx], INT_MIN, INT_MAX, &errstr); + n = (int)strtonum(lines[idx], INT_MIN, INT_MAX, &errstr); if (errstr) { printf("Failed to convert %s to int. Returning NULL\n", lines[idx]); exit(1); diff --git a/src/linkedlist.c b/src/lflinkedlist.c similarity index 99% rename from src/linkedlist.c rename to src/lflinkedlist.c index 32da095..1690a6e 100644 --- a/src/linkedlist.c +++ b/src/lflinkedlist.c @@ -1,7 +1,7 @@ #include #include -#include "linkedlist.h" +#include "lflinkedlist.h" void ll_init(List* list, void (*destroy)(void *data)) { list->size = 0; diff --git a/src/math.c b/src/lfmath.c similarity index 82% rename from src/math.c rename to src/lfmath.c index 13a4647..cea4835 100644 --- a/src/math.c +++ b/src/lfmath.c @@ -1,6 +1,6 @@ #include -#include "math.h" +#include "lfmath.h" int max_int(int a, int b) { if (a > b) { @@ -18,7 +18,7 @@ int min_int(int a, int b) { int binstr_to_int(const char *s) { int n = 0, m = 1; - for (size_t i = strlen(s) - 1; i >= 0; --i) { + for (int i = (int)strlen(s) - 1; i >= 0; --i) { if (s[i] == '1') { n += m; } diff --git a/src/set.c b/src/lfset.c similarity index 99% rename from src/set.c rename to src/lfset.c index 750c796..b726e51 100644 --- a/src/set.c +++ b/src/lfset.c @@ -1,4 +1,4 @@ -#include "set.h" +#include "lfset.h" void set_init(Set* set, int (*match)(const void* a, const void* b), void (*destroy)(void* data)) { diff --git a/src/stack.c b/src/lfstack.c similarity index 96% rename from src/stack.c rename to src/lfstack.c index 64858fe..022a8f4 100644 --- a/src/stack.c +++ b/src/lfstack.c @@ -1,4 +1,4 @@ -#include "stack.h" +#include "lfstack.h" void stack_init(Stack* stack, void (*destroy)(void* data)) { ll_init(stack, destroy); diff --git a/tests/tests.c b/tests/tests.c index 4899858..c6a948a 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -1,10 +1,11 @@ #include #include -#include "linkedlist.h" -#include "set.h" -#include "stack.h" -#include "binarytree.h" +#include "lflinkedlist.h" +#include "lfset.h" +#include "lfstack.h" +#include "lfbinarytree.h" +#include "lfmath.h" void print_ll(List* list) { for (ListNode* node = list->head; node != NULL; node = node->next) { @@ -146,10 +147,22 @@ void test_bintree() { bintree_destroy(tree); } +void test_math() { + printf("\n--- MATH TEST ---\n"); + int i = 1, j = 2; + printf("Between %d and %d, %d is larger\n", i, j, max_int(i, j)); + printf("Between %d and %d, %d is smaller\n", i, j, min_int(i, j)); + + char *s = "1010110"; + printf("Binary: %s\n", s); + printf("Decimal: %d\n", binstr_to_int(s)); +} + int main() { test_ll(); test_set(); test_stack(); test_bintree(); + test_math(); return 0; } \ No newline at end of file