aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-01-14 15:50:09 +0100
committerCharles <sircharlesaze@gmail.com>2020-01-14 15:50:09 +0100
commit1ab2fedd108b26c9624454a897e2c518aaff7d32 (patch)
treefff428b72e018b2f17bea7c3cd5eb19ff096ea7f
parent66bfb5efc23b4dd9819bf70b5a709c81ccf7a820 (diff)
downloadlibasm_test-1ab2fedd108b26c9624454a897e2c518aaff7d32.tar.gz
libasm_test-1ab2fedd108b26c9624454a897e2c518aaff7d32.tar.bz2
libasm_test-1ab2fedd108b26c9624454a897e2c518aaff7d32.zip
Linux portability, moved tests to test/ dir
-rw-r--r--Makefile14
-rw-r--r--main.c2
-rw-r--r--test/ft_atoi_base_test.c (renamed from ft_atoi_base_test.c)2
-rw-r--r--test/ft_list_push_front_test.c (renamed from ft_list_push_front_test.c)0
-rw-r--r--test/ft_list_remove_if_test.c (renamed from ft_list_remove_if_test.c)0
-rw-r--r--test/ft_list_size_test.c (renamed from ft_list_size_test.c)0
-rw-r--r--test/ft_list_sort_test.c (renamed from ft_list_sort_test.c)0
-rw-r--r--test/ft_read_test.c (renamed from ft_read_test.c)0
-rw-r--r--test/ft_strcmp_test.c (renamed from ft_strcmp_test.c)19
-rw-r--r--test/ft_strcpy_test.c (renamed from ft_strcpy_test.c)0
-rw-r--r--test/ft_strdup_test.c (renamed from ft_strdup_test.c)0
-rw-r--r--test/ft_strlen_test.c (renamed from ft_strlen_test.c)0
-rw-r--r--test/ft_write_test.c (renamed from ft_write_test.c)0
13 files changed, 28 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index ddc3162..468998a 100644
--- a/Makefile
+++ b/Makefile
@@ -16,13 +16,13 @@ LDFLAGS = -L$(LIBASM_PATH) -lasm
NAME = runtest
SRC = main.c \
helper.c \
- ft_strlen_test.c \
- ft_strcpy_test.c \
- ft_strcmp_test.c \
- ft_write_test.c \
- ft_read_test.c \
- ft_strdup_test.c \
- ft_atoi_base_test.c \
+ test/ft_strlen_test.c \
+ test/ft_strcpy_test.c \
+ test/ft_strcmp_test.c \
+ test/ft_write_test.c \
+ test/ft_read_test.c \
+ test/ft_strdup_test.c \
+ test/ft_atoi_base_test.c \
functions_reference/ref_ft_atoi_base.c
#ft_list_push_front_test.c ft_list_size_test.c \
# ft_list_sort_test.c ft_list_remove_if_test.c \
diff --git a/main.c b/main.c
index 840d73c..b81a1ed 100644
--- a/main.c
+++ b/main.c
@@ -6,8 +6,10 @@ main(void)
ft_strlen_test();
ft_strcpy_test();
ft_strcmp_test();
+#ifndef __linux__
ft_write_test();
ft_read_test();
+#endif
ft_strdup_test();
ft_atoi_base_test();
diff --git a/ft_atoi_base_test.c b/test/ft_atoi_base_test.c
index 653d6b1..8801565 100644
--- a/ft_atoi_base_test.c
+++ b/test/ft_atoi_base_test.c
@@ -3,8 +3,8 @@
static int expected_ret;
static int actual_ret;
+ /* asm("movq $0xffffffffffffffff, %rax"); \ */
#define FT_ATOI_BASE_EXPECT(str, base) do { \
- asm("movq $0xffffffffffffffff, %rax"); \
actual_ret = ft_atoi_base(str, base); \
expected_ret = ref_ft_atoi_base(str, base); \
if (actual_ret != expected_ret) \
diff --git a/ft_list_push_front_test.c b/test/ft_list_push_front_test.c
index 411194e..411194e 100644
--- a/ft_list_push_front_test.c
+++ b/test/ft_list_push_front_test.c
diff --git a/ft_list_remove_if_test.c b/test/ft_list_remove_if_test.c
index e574949..e574949 100644
--- a/ft_list_remove_if_test.c
+++ b/test/ft_list_remove_if_test.c
diff --git a/ft_list_size_test.c b/test/ft_list_size_test.c
index 80394d7..80394d7 100644
--- a/ft_list_size_test.c
+++ b/test/ft_list_size_test.c
diff --git a/ft_list_sort_test.c b/test/ft_list_sort_test.c
index e9fe2da..e9fe2da 100644
--- a/ft_list_sort_test.c
+++ b/test/ft_list_sort_test.c
diff --git a/ft_read_test.c b/test/ft_read_test.c
index 50a85bd..50a85bd 100644
--- a/ft_read_test.c
+++ b/test/ft_read_test.c
diff --git a/ft_strcmp_test.c b/test/ft_strcmp_test.c
index db106df..fa62157 100644
--- a/ft_strcmp_test.c
+++ b/test/ft_strcmp_test.c
@@ -24,7 +24,24 @@ ac tortor et lectus fermentum lobortis eu at mauris. Vestibulum sit amet posuere
tortor, sit amet consequat amet."));
}
-#define FT_STRCMP_EXPECT(s1, s2) expect_int(strcmp(s1, s2), ft_strcmp(s1, s2))
+int strcmp_expected;
+int strcmp_actual;
+
+#ifdef __linux__
+# define FT_STRCMP_EXPECT(s1, s2) do { \
+ strcmp_expected = strcmp(s1, s2); \
+ strcmp_actual = ft_strcmp(s1, s2); \
+ if ((strcmp_expected < 0 && strcmp_actual < 0) || \
+ (strcmp_expected > 0 && strcmp_actual > 0) || \
+ (strcmp_expected == 0 && strcmp_actual == 0)) \
+ print_ok(); \
+ else \
+ printf("KO: [COMPARE]: ft_strcmp.s: expected: %d got: %d\n", \
+ strcmp_expected, strcmp_actual); \
+} while (0);
+#else
+# define FT_STRCMP_EXPECT(s1, s2) expect_int(strcmp(s1, s2), ft_strcmp(s1, s2))
+#endif
static void
ft_strcmp_test_compare(void)
diff --git a/ft_strcpy_test.c b/test/ft_strcpy_test.c
index c8ec474..c8ec474 100644
--- a/ft_strcpy_test.c
+++ b/test/ft_strcpy_test.c
diff --git a/ft_strdup_test.c b/test/ft_strdup_test.c
index 5ca7850..5ca7850 100644
--- a/ft_strdup_test.c
+++ b/test/ft_strdup_test.c
diff --git a/ft_strlen_test.c b/test/ft_strlen_test.c
index 7229316..7229316 100644
--- a/ft_strlen_test.c
+++ b/test/ft_strlen_test.c
diff --git a/ft_write_test.c b/test/ft_write_test.c
index 1c14244..1c14244 100644
--- a/ft_write_test.c
+++ b/test/ft_write_test.c