-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9a14ee1
Showing
33 changed files
with
1,828 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: check coding style | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: install dependencies | ||
run: sudo apt-get install -y gcc libncurses5-dev | ||
- name: coding-style-install | ||
run: git clone https://github.com/Epitech/coding-style-checker.git | ||
- name: coding-style | ||
run: | | ||
output=$(./coding-style-checker/coding-style.sh . .) | ||
echo "$output" | ||
echo "\n======== errors ========\n" | ||
cat coding-style-reports.log | ||
echo "\n========================\n" | ||
errors=$(echo "$output" | grep -oP '\d+(?= coding style error)' || true) | ||
if (( errors != 3 )); then | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# IntelliJ IDEA | ||
.idea | ||
|
||
# Prerequisites | ||
*.d | ||
|
||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Linker output | ||
*.ilk | ||
*.map | ||
*.exp | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# Debug files | ||
*.dSYM/ | ||
*.su | ||
*.idb | ||
*.pdb | ||
|
||
# Kernel Module Compile Results | ||
*.mod* | ||
*.cmd | ||
.tmp_versions/ | ||
modules.order | ||
Module.symvers | ||
Mkfile.old | ||
dkms.conf |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## | ||
## EPITECH PROJECT, 2023 | ||
## my_sokoban | ||
## File description: | ||
## Makefile | ||
## | ||
|
||
CC = gcc -c -g3 | ||
|
||
ARRC = ar rc | ||
|
||
SRCS = src/algorithm/key_hash.c \ | ||
src/dump/hashtable_dump.c \ | ||
src/manager/hashtable_delete.c \ | ||
src/manager/hashtable_insert.c \ | ||
src/provider/hashtable_provider.c \ | ||
src/search/hashtable_search.c \ | ||
src/utils/my_put_int.c \ | ||
src/utils/my_str_dup.c \ | ||
src/utils/my_str_utils.c \ | ||
|
||
HRCS = include | ||
|
||
TARGET = libhashtable.a | ||
|
||
OBJS = $(SRCS:.c=.o) | ||
|
||
CFLAGS = -I $(HRCS) | ||
|
||
all: $(TARGET) | ||
|
||
$(TARGET): $(OBJS) | ||
$(ARRC) $(TARGET) $(OBJS) | ||
|
||
clean: | ||
rm -f $(OBJS) | ||
|
||
fclean: clean | ||
rm -f $(TARGET) | ||
|
||
re: fclean all | ||
|
||
.PHONY: all clean fclean re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Elementary Programming in C - Secured | ||
Hashtable lib project for semester 1 of the Epitech Elementary Programming in C module (B-CPE-110). | ||
|
||
## Introduction | ||
The hash function is the central element of a hash table, defining which table index should be | ||
used to store the data. A hash function is a mathematical function that converts any numerical | ||
data into an output string comprising a fixed number of characters or a positive integer. | ||
|
||
The full description of the project can be found in [subject.pdf](pdf/B-PSU-100_my_sokoban.pdf). | ||
|
||
## Prerequisites | ||
- [Make](https://www.gnu.org/software/make/) | ||
- [GCC](https://gcc.gnu.org/) | ||
- [LibC](https://www.gnu.org/software/libc/) | ||
|
||
## Installation | ||
``` | ||
B-PSU-100> git clone [email protected]:WilliamJlvt/secured.git | ||
... | ||
B-PSU-100> make | ||
... | ||
``` | ||
It will generate a library binary called `libhashtable.a` | ||
|
||
## Results | ||
| test | passed | results | | ||
|-------------------------------------|--------|---------| | ||
| 01 - Algorithm app. - Hash function | 3/4 | 75% | | ||
| 02 - Algorithm app. - Hash table | 5/5 | 100% | | ||
| 03 - Basics | 6/6 | 100% | | ||
| 04 - Data structure | 5/5 | 100% | | ||
| 05 - Optimization | 5/5 | 100% | | ||
| 06 - Robustness | 10/10 | 100% | | ||
| total | 34/35 | 97.1% | | ||
|
||
## Coding style | ||
All the source code has been written according to the [Epitech C Coding Style](https://williamjlvt.github.io/assets/coding_style/epitech_c_coding_style.pdf). | ||
#### errors | ||
| Fatal | Major | Minor | Info | | ||
|-------|--------|-------|------| | ||
| 0 | 0 | 0 | 0 | | ||
|
||
## Unit tests | ||
Unit tests are written using the [Criterion](https://github.com/Snaipe/Criterion) framework. | ||
You can find the tests in the [bonus](bonus) directory. Just run `make lcriterion` to build the tests and `./hashtable` to run them. | ||
|
||
## Authors | ||
* **William JOLIVET** ([GitHub](https://github.com/WilliamJlvt) / [LinkedIn](https://www.linkedin.com/in/william-jolivet-64951a24b/)) | ||
* **Feyza MEDDAH** ([GitHub](https://github.com/etsuzaku)) | ||
|
||
## License | ||
This project is licensed under the GNU Public License version 3.0 - see the [LICENSE](LICENSE) file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
## | ||
## EPITECH PROJECT, 2023 | ||
## my_sokoban | ||
## File description: | ||
## Makefile | ||
## | ||
|
||
CC = gcc -g3 | ||
|
||
LCRITERION = --coverage -lcriterion | ||
|
||
VALGRIND = valgrind | ||
|
||
SRCS = ../src/algorithm/key_hash.c \ | ||
../src/dump/hashtable_dump.c \ | ||
../src/manager/hashtable_delete.c \ | ||
../src/manager/hashtable_insert.c \ | ||
../src/provider/hashtable_provider.c \ | ||
../src/search/hashtable_search.c \ | ||
../src/utils/my_put_int.c \ | ||
../src/utils/my_str_dup.c \ | ||
../src/utils/my_str_utils.c \ | ||
|
||
TEST_SRCS = lcriterion/lcriterion_utils.c \ | ||
lcriterion/insert_test.c \ | ||
lcriterion/delete_test.c \ | ||
lcriterion/dump_test.c \ | ||
|
||
MAIN_SRCS = main.c | ||
|
||
HRCS = ../include \ | ||
lcriterion/lcriterion.h \ | ||
|
||
TARGET = hashtable | ||
|
||
BUILD_DIR = build | ||
|
||
OBJS = $(SRCS:.c=.o) | ||
TEST_OBJS = $(TEST_SRCS:.c=.o) | ||
MAIN_OBJS = $(MAIN_SRCS:.c=.o) | ||
|
||
all: | ||
echo "USAGE\: make main OR make lcriterion" | ||
|
||
$(TARGET): $(OBJS) $(TEST_OBJS) | ||
$(CC) -o $(TARGET) $(OBJS) $(TEST_OBJS) $(LCRITERION) | ||
|
||
main: $(OBJS) $(MAIN_OBJS) | ||
$(CC) -o $(TARGET) $(OBJS) $(MAIN_OBJS) | ||
clear | ||
./$(TARGET) | ||
|
||
mainv: $(OBJS) $(MAIN_OBJS) | ||
$(CC) -o $(TARGET) $(OBJS) $(MAIN_OBJS) | ||
clear | ||
$(VALGRIND) ./$(TARGET) | ||
|
||
lcriterion: $(OBJS) $(TEST_OBJS) | ||
$(CC) -o $(TARGET) $(OBJS) $(TEST_OBJS) $(LCRITERION) | ||
clear | ||
./$(TARGET) | ||
|
||
re: fclean all | ||
|
||
clean: | ||
rm -f $(OBJS) | ||
rm -f $(TEST_OBJS) | ||
rm -f $(MAIN_OBJS) | ||
rm -rf $(BUILD_DIR) | ||
|
||
fclean: clean | ||
rm -f $(TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** secured | ||
** File description: | ||
** create_test.c | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** secured | ||
** File description: | ||
** delete_test.c | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <criterion/criterion.h> | ||
#include "../../include/hashtable.h" | ||
|
||
Test(delete, delete_1) | ||
{ | ||
hashtable_t *ht = new_hashtable(hash, 10); | ||
|
||
cr_assert_eq(ht_insert(ht, "key", "value"), 0); | ||
cr_assert_not_null(ht_search(ht, "key")); | ||
cr_assert_str_eq(ht_search(ht, "key"), "value"); | ||
cr_assert_eq(ht_delete(ht, "key"), 0); | ||
cr_assert_null(ht_search(ht, "key")); | ||
delete_hashtable(ht); | ||
} | ||
|
||
Test(delete, delete_2) | ||
{ | ||
hashtable_t *ht = new_hashtable(hash, 10); | ||
|
||
cr_assert_eq(ht_insert(ht, "key", "value"), 0); | ||
cr_assert_eq(ht_insert(ht, "key2", "value2"), 0); | ||
cr_assert_not_null(ht_search(ht, "key")); | ||
cr_assert_str_eq(ht_search(ht, "key"), "value"); | ||
cr_assert_not_null(ht_search(ht, "key2")); | ||
cr_assert_str_eq(ht_search(ht, "key2"), "value2"); | ||
cr_assert_eq(ht_delete(ht, "key"), 0); | ||
cr_assert_null(ht_search(ht, "key")); | ||
cr_assert_not_null(ht_search(ht, "key2")); | ||
cr_assert_str_eq(ht_search(ht, "key2"), "value2"); | ||
delete_hashtable(ht); | ||
} | ||
|
||
Test(delete, delete_3) | ||
{ | ||
hashtable_t *ht = new_hashtable(hash, 10); | ||
|
||
cr_assert_eq(ht_insert(ht, "key", "value"), 0); | ||
cr_assert_eq(ht_delete(ht, "key2"), 84); | ||
delete_hashtable(ht); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** secured | ||
** File description: | ||
** destroy_test.c | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <criterion/criterion.h> | ||
#include "../../include/hashtable.h" | ||
|
||
Test(destroy, destroy_1) | ||
{ | ||
hashtable_t *ht = new_hashtable(hash, 10); | ||
|
||
cr_assert_eq(ht_insert(ht, "key", "value"), 0); | ||
cr_assert_not_null(ht_search(ht, "key")); | ||
cr_assert_str_eq(ht_search(ht, "key"), "value"); | ||
delete_hashtable(ht); | ||
} |
Oops, something went wrong.