lib

morphux C utility library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/lib

commit 8605096e15de6f1ed76ea062c3269a5d98556d83
parent 7d9d0a5d666cd45cc51f124d0f69e9dac7eeeb81
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon, 29 May 2017 10:32:51 +0200

Add(Tests): Add test for chdir mockup

Diffstat:
Mtests/test_tests.c | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/tests/test_tests.c b/tests/test_tests.c @@ -1,6 +1,7 @@ /* Inception BWAAAAAAH */ #include "test.h" +#include <limits.h> TEST(test_all_empty) { int st, fd[2]; @@ -264,6 +265,17 @@ TEST(test_fail_fork) { return TEST_SUCCESS; } +TEST(test_fail_chdir) { + char oldpwd[PATH_MAX]; + + getcwd(oldpwd, PATH_MAX); + TEST_ASSERT(chdir("/") != -1, "Should have suceed (Or your computer is broken)"); + set_chdir_fail(1); + TEST_ASSERT(chdir("/") != -1, "Should have suceed (Or your computer is broken)"); + TEST_ASSERT(chdir("/") == -1, "Should have failed"); + chdir(oldpwd); + return TEST_SUCCESS; +} TEST(test_fail_cleanup) { unlink(TMP_FD_FN); @@ -289,4 +301,5 @@ void register_tests_tests(void) { reg_test("fake_functions", test_fail_cleanup); reg_test("fake_functions", test_fail_mkdir); reg_test("fake_functions", test_fail_fork); + reg_test("fake_functions", test_fail_chdir); }