aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-02-12 23:14:11 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-12 23:36:42 +0100
commite6f53e82b0f8ae1cff3749ea3476c2074c325d7b (patch)
tree8fb26b636a6959f036d74c7ad9c28e2e2290495d /test
parentf178a21e2560d9375227dbf6751a54f12e1033b2 (diff)
downloadlibft-e6f53e82b0f8ae1cff3749ea3476c2074c325d7b.tar.gz
libft-e6f53e82b0f8ae1cff3749ea3476c2074c325d7b.tar.bz2
libft-e6f53e82b0f8ae1cff3749ea3476c2074c325d7b.zip
Added ctype tests, ignore htnew tests
Diffstat (limited to 'test')
-rw-r--r--test/include/libft_test.h1
-rwxr-xr-xtest/libft_testbin45308 -> 53772 bytes
-rw-r--r--test/src/ctype/test_ft_isalnum.c15
-rw-r--r--test/src/ctype/test_ft_isalpha.c15
-rw-r--r--test/src/ctype/test_ft_isascii.c15
-rw-r--r--test/src/ctype/test_ft_isblank.c15
-rw-r--r--test/src/ctype/test_ft_isdigit.c15
-rw-r--r--test/src/ctype/test_ft_isprint.c15
-rw-r--r--test/src/ctype/test_ft_isspace.c15
-rw-r--r--test/src/ctype/test_ft_todigit.c20
-rw-r--r--test/src/ctype/test_ft_tolower.c15
-rw-r--r--test/src/ctype/test_ft_toupper.c15
-rw-r--r--test/src/ht/test_ft_htnew.c16
-rw-r--r--test/src/main.c10
-rw-r--r--test/src/runner/test_runner_ctype.c64
-rw-r--r--test/src/runner/test_runner_ht.c12
16 files changed, 257 insertions, 1 deletions
diff --git a/test/include/libft_test.h b/test/include/libft_test.h
index c5eb5e2..ff99eec 100644
--- a/test/include/libft_test.h
+++ b/test/include/libft_test.h
@@ -2,6 +2,7 @@
# define LIBFT_TEST_H
# include <string.h>
+# include <ctype.h>
# include <sys/wait.h>
# include "unity.h"
diff --git a/test/libft_test b/test/libft_test
index 050602b..3af5a2f 100755
--- a/test/libft_test
+++ b/test/libft_test
Binary files differ
diff --git a/test/src/ctype/test_ft_isalnum.c b/test/src/ctype/test_ft_isalnum.c
new file mode 100644
index 0000000..0019a03
--- /dev/null
+++ b/test/src/ctype/test_ft_isalnum.c
@@ -0,0 +1,15 @@
+#include "libft_test.h"
+
+TEST_GROUP(ft_isalnum);
+
+TEST_SETUP(ft_isalnum)
+{}
+
+TEST_TEAR_DOWN(ft_isalnum)
+{}
+
+TEST(ft_isalnum, base)
+{
+ for (int i = 0; i <= UCHAR_MAX; i++)
+ TEST_ASSERT_EQUAL(!!isalnum(i), !!ft_isalnum(i));
+}
diff --git a/test/src/ctype/test_ft_isalpha.c b/test/src/ctype/test_ft_isalpha.c
new file mode 100644
index 0000000..9846985
--- /dev/null
+++ b/test/src/ctype/test_ft_isalpha.c
@@ -0,0 +1,15 @@
+#include "libft_test.h"
+
+TEST_GROUP(ft_isalpha);
+
+TEST_SETUP(ft_isalpha)
+{}
+
+TEST_TEAR_DOWN(ft_isalpha)
+{}
+
+TEST(ft_isalpha, base)
+{
+ for (int i = 0; i <= UCHAR_MAX; i++)
+ TEST_ASSERT_EQUAL(!!isalpha(i), !!ft_isalpha(i));
+}
diff --git a/test/src/ctype/test_ft_isascii.c b/test/src/ctype/test_ft_isascii.c
new file mode 100644
index 0000000..c052571
--- /dev/null
+++ b/test/src/ctype/test_ft_isascii.c
@@ -0,0 +1,15 @@
+#include "libft_test.h"
+
+TEST_GROUP(ft_isascii);
+
+TEST_SETUP(ft_isascii)
+{}
+
+TEST_TEAR_DOWN(ft_isascii)
+{}
+
+TEST(ft_isascii, base)
+{
+ for (int i = 0; i < UCHAR_MAX; i++)
+ TEST_ASSERT_EQUAL(!!isascii(i), !!ft_isascii(i));
+}
diff --git a/test/src/ctype/test_ft_isblank.c b/test/src/ctype/test_ft_isblank.c
new file mode 100644
index 0000000..3c8460f
--- /dev/null
+++ b/test/src/ctype/test_ft_isblank.c
@@ -0,0 +1,15 @@
+#include "libft_test.h"
+
+TEST_GROUP(ft_isblank);
+
+TEST_SETUP(ft_isblank)
+{}
+
+TEST_TEAR_DOWN(ft_isblank)
+{}
+
+TEST(ft_isblank, base)
+{
+ for (int i = 0; i <= UCHAR_MAX; i++)
+ TEST_ASSERT_EQUAL(!!isblank(i), !!ft_isblank(i));
+}
diff --git a/test/src/ctype/test_ft_isdigit.c b/test/src/ctype/test_ft_isdigit.c
new file mode 100644
index 0000000..74c210b
--- /dev/null
+++ b/test/src/ctype/test_ft_isdigit.c
@@ -0,0 +1,15 @@
+#include "libft_test.h"
+
+TEST_GROUP(ft_isdigit);
+
+TEST_SETUP(ft_isdigit)
+{}
+
+TEST_TEAR_DOWN(ft_isdigit)
+{}
+
+TEST(ft_isdigit, base)
+{
+ for (int i = 0; i <= UCHAR_MAX; i++)
+ TEST_ASSERT_EQUAL(!!isdigit(i), !!ft_isdigit(i));
+}
diff --git a/test/src/ctype/test_ft_isprint.c b/test/src/ctype/test_ft_isprint.c
new file mode 100644
index 0000000..0f15661
--- /dev/null
+++ b/test/src/ctype/test_ft_isprint.c
@@ -0,0 +1,15 @@
+#include "libft_test.h"
+
+TEST_GROUP(ft_isprint);
+
+TEST_SETUP(ft_isprint)
+{}
+
+TEST_TEAR_DOWN(ft_isprint)
+{}
+
+TEST(ft_isprint, base)
+{
+ for (int i = 0; i <= UCHAR_MAX; i++)
+ TEST_ASSERT_EQUAL(!!isprint(i), !!ft_isprint(i));
+}
diff --git a/test/src/ctype/test_ft_isspace.c b/test/src/ctype/test_ft_isspace.c
new file mode 100644
index 0000000..f94a1ea
--- /dev/null
+++ b/test/src/ctype/test_ft_isspace.c
@@ -0,0 +1,15 @@
+#include "libft_test.h"
+
+TEST_GROUP(ft_isspace);
+
+TEST_SETUP(ft_isspace)
+{}
+
+TEST_TEAR_DOWN(ft_isspace)
+{}
+
+TEST(ft_isspace, base)
+{
+ for (int i = 0; i <= UCHAR_MAX; i++)
+ TEST_ASSERT_EQUAL(!!isspace(i), !!ft_isspace(i));
+}
diff --git a/test/src/ctype/test_ft_todigit.c b/test/src/ctype/test_ft_todigit.c
new file mode 100644
index 0000000..cd8d9f3
--- /dev/null
+++ b/test/src/ctype/test_ft_todigit.c
@@ -0,0 +1,20 @@
+#include "libft_test.h"
+
+TEST_GROUP(ft_todigit);
+
+TEST_SETUP(ft_todigit)
+{}
+
+TEST_TEAR_DOWN(ft_todigit)
+{}
+
+TEST(ft_todigit, base)
+{
+ for (int i = 0; i <= UCHAR_MAX; i++)
+ {
+ if (isdigit(i))
+ TEST_ASSERT_EQUAL(i - '0', ft_todigit(i));
+ else
+ TEST_ASSERT_EQUAL(-1, ft_todigit(i));
+ }
+}
diff --git a/test/src/ctype/test_ft_tolower.c b/test/src/ctype/test_ft_tolower.c
new file mode 100644
index 0000000..9465544
--- /dev/null
+++ b/test/src/ctype/test_ft_tolower.c
@@ -0,0 +1,15 @@
+#include "libft_test.h"
+
+TEST_GROUP(ft_tolower);
+
+TEST_SETUP(ft_tolower)
+{}
+
+TEST_TEAR_DOWN(ft_tolower)
+{}
+
+TEST(ft_tolower, base)
+{
+ for (int i = 0; i <= UCHAR_MAX; i++)
+ TEST_ASSERT_EQUAL(tolower(i), ft_tolower(i));
+}
diff --git a/test/src/ctype/test_ft_toupper.c b/test/src/ctype/test_ft_toupper.c
new file mode 100644
index 0000000..b23c08b
--- /dev/null
+++ b/test/src/ctype/test_ft_toupper.c
@@ -0,0 +1,15 @@
+#include "libft_test.h"
+
+TEST_GROUP(ft_toupper);
+
+TEST_SETUP(ft_toupper)
+{}
+
+TEST_TEAR_DOWN(ft_toupper)
+{}
+
+TEST(ft_toupper, base)
+{
+ for (int i = 0; i <= UCHAR_MAX; i++)
+ TEST_ASSERT_EQUAL(toupper(i), ft_toupper(i));
+}
diff --git a/test/src/ht/test_ft_htnew.c b/test/src/ht/test_ft_htnew.c
index 2696e7f..b8729bd 100644
--- a/test/src/ht/test_ft_htnew.c
+++ b/test/src/ht/test_ft_htnew.c
@@ -1,5 +1,16 @@
-#include "libft_test.h"
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* test_ft_htnew.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/12 22:30:06 by cacharle #+# #+# */
+/* Updated: 2020/02/12 22:30:09 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+#include "libft_test.h"
TEST_GROUP(ft_htnew);
@@ -13,6 +24,7 @@ int helper_segfault_pid;
TEST(ft_htnew, segfault)
{
+ TEST_IGNORE();
TEST_ASSERT_SEGFAULT(ft_htnew(10));
TEST_ASSERT_SEGFAULT(ft_htnew(0));
TEST_ASSERT_SEGFAULT(ft_htnew((1 << 14) + 1));
@@ -20,6 +32,7 @@ TEST(ft_htnew, segfault)
TEST(ft_htnew, error_null)
{
+ TEST_IGNORE();
TEST_ASSERT_NOT_NULL(ft_htnew(10)); // leak
TEST_ASSERT_NULL(ft_htnew(0));
TEST_ASSERT_NULL(ft_htnew((1 << 14) + 1));
@@ -27,6 +40,7 @@ TEST(ft_htnew, error_null)
TEST(ft_htnew, happy_path)
{
+ TEST_IGNORE();
t_ftht *ht;
ht = ft_htnew(10);
diff --git a/test/src/main.c b/test/src/main.c
index a81bc8f..9ca4fe4 100644
--- a/test/src/main.c
+++ b/test/src/main.c
@@ -6,6 +6,16 @@ static void run_all_test(void)
RUN_TEST_GROUP(ft_htnew);
RUN_TEST_GROUP(ft_htget);
RUN_TEST_GROUP(ft_htset);
+ RUN_TEST_GROUP(ft_isalnum);
+ RUN_TEST_GROUP(ft_isalpha);
+ RUN_TEST_GROUP(ft_isascii);
+ RUN_TEST_GROUP(ft_isblank);
+ RUN_TEST_GROUP(ft_isdigit);
+ RUN_TEST_GROUP(ft_isprint);
+ RUN_TEST_GROUP(ft_isspace);
+ RUN_TEST_GROUP(ft_todigit);
+ RUN_TEST_GROUP(ft_tolower);
+ RUN_TEST_GROUP(ft_toupper);
}
int main(int argc, const char **argv)
diff --git a/test/src/runner/test_runner_ctype.c b/test/src/runner/test_runner_ctype.c
new file mode 100644
index 0000000..7f9148e
--- /dev/null
+++ b/test/src/runner/test_runner_ctype.c
@@ -0,0 +1,64 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* test_runner_ctype.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/12 22:44:43 by cacharle #+# #+# */
+/* Updated: 2020/02/12 23:13:02 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_test.h"
+
+TEST_GROUP_RUNNER(ft_isalnum)
+{
+ RUN_TEST_CASE(ft_isalnum, base);
+}
+
+TEST_GROUP_RUNNER(ft_isalpha)
+{
+ RUN_TEST_CASE(ft_isalpha, base);
+}
+
+TEST_GROUP_RUNNER(ft_isascii)
+{
+ RUN_TEST_CASE(ft_isascii, base);
+}
+
+TEST_GROUP_RUNNER(ft_isblank)
+{
+ RUN_TEST_CASE(ft_isblank, base);
+}
+
+TEST_GROUP_RUNNER(ft_isdigit)
+{
+ RUN_TEST_CASE(ft_isdigit, base);
+}
+
+TEST_GROUP_RUNNER(ft_isprint)
+{
+ RUN_TEST_CASE(ft_isprint, base);
+}
+
+TEST_GROUP_RUNNER(ft_isspace)
+{
+ RUN_TEST_CASE(ft_isspace, base);
+}
+
+TEST_GROUP_RUNNER(ft_todigit)
+{
+ RUN_TEST_CASE(ft_todigit, base);
+}
+
+TEST_GROUP_RUNNER(ft_tolower)
+{
+ RUN_TEST_CASE(ft_tolower, base);
+}
+
+TEST_GROUP_RUNNER(ft_toupper)
+{
+ RUN_TEST_CASE(ft_toupper, base);
+}
+
diff --git a/test/src/runner/test_runner_ht.c b/test/src/runner/test_runner_ht.c
index d8718af..de20c5b 100644
--- a/test/src/runner/test_runner_ht.c
+++ b/test/src/runner/test_runner_ht.c
@@ -1,3 +1,15 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* test_runner_ht.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/12 22:44:39 by cacharle #+# #+# */
+/* Updated: 2020/02/12 22:47:11 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
#include "libft_test.h"
TEST_GROUP_RUNNER(ft_htnew)