Skip to content

Commit

Permalink
feature/issue#66 (#67)
Browse files Browse the repository at this point in the history
* implement ft_isblank

* add test
  • Loading branch information
rask24 committed Apr 15, 2024
1 parent ecd1c45 commit cc2f508
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ TYPE_DIR = ft_type
SRC += $(TYPE_DIR)/ft_isalnum.c \
$(TYPE_DIR)/ft_isalpha.c \
$(TYPE_DIR)/ft_isascii.c \
$(TYPE_DIR)/ft_isblank.c \
$(TYPE_DIR)/ft_isdigit.c \
$(TYPE_DIR)/ft_isprint.c \
$(TYPE_DIR)/ft_isspace.c \
Expand Down
16 changes: 16 additions & 0 deletions ft_type/ft_isblank.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isblank.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: reasuke <reasuke@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/15 16:06:34 by reasuke #+# #+# */
/* Updated: 2024/04/15 16:07:01 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isblank(int c)
{
return ((c == ' ') || (c == '\t'));
}
3 changes: 2 additions & 1 deletion include/ft_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <reasuke@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/24 12:44:55 by reasuke #+# #+# */
/* Updated: 2024/02/24 16:26:09 by reasuke ### ########.fr */
/* Updated: 2024/04/15 16:08:56 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -16,6 +16,7 @@
int ft_isalnum(int c);
int ft_isalpha(int c);
int ft_isascii(int c);
int ft_isblank(int c);
int ft_isdigit(int c);
int ft_isprint(int c);
int ft_isspace(int c);
Expand Down
17 changes: 17 additions & 0 deletions test/unit/test_type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2024, reasuke.

#include "gtest/gtest.h"

extern "C" {
#include "ft_type.h"
}

TEST(ft_isblank, test) {
EXPECT_TRUE(ft_isblank(' '));
EXPECT_TRUE(ft_isblank('\t'));

EXPECT_FALSE(ft_isblank('a'));
EXPECT_FALSE(ft_isblank('0'));
EXPECT_FALSE(ft_isblank('\0'));
EXPECT_FALSE(ft_isblank('<'));
}
1 change: 1 addition & 0 deletions unit_test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ TEST_SRC = $(TEST_DIR)/test_strcmp.cpp \
$(TEST_DIR)/test_strndup.cpp \
$(TEST_DIR)/test_strtol.cpp \
$(TEST_DIR)/test_math.cpp \
$(TEST_DIR)/test_type.cpp \
$(TEST_DIR)/test_lst_before.cpp \
$(TEST_DIR)/test_file_to_lines.cpp
TEST_OBJ = $(patsubst $(TEST_DIR)/%.cpp, $(TEST_BUILD_DIR)/%.o, $(TEST_SRC))
Expand Down

0 comments on commit cc2f508

Please sign in to comment.