-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: libuv/libuv#350 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Saúl Ibarra Corretgé <[email protected]>
- Loading branch information
Showing
9 changed files
with
228 additions
and
7 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
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
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
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
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
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
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,49 @@ | ||
#include "uv.h" | ||
#include "task.h" | ||
#include <string.h> | ||
|
||
#define PATHMAX 1024 | ||
#define SMALLPATH 1 | ||
|
||
TEST_IMPL(homedir) { | ||
char homedir[PATHMAX]; | ||
size_t len; | ||
char last; | ||
int r; | ||
|
||
/* Test the normal case */ | ||
len = sizeof homedir; | ||
homedir[0] = '\0'; | ||
ASSERT(strlen(homedir) == 0); | ||
r = uv_os_homedir(homedir, &len); | ||
ASSERT(r == 0); | ||
ASSERT(strlen(homedir) == len); | ||
ASSERT(len > 0); | ||
ASSERT(homedir[len] == '\0'); | ||
|
||
if (len > 1) { | ||
last = homedir[len - 1]; | ||
#ifdef _WIN32 | ||
ASSERT(last != '\\'); | ||
#else | ||
ASSERT(last != '/'); | ||
#endif | ||
} | ||
|
||
/* Test the case where the buffer is too small */ | ||
len = SMALLPATH; | ||
r = uv_os_homedir(homedir, &len); | ||
ASSERT(r == UV_ENOBUFS); | ||
ASSERT(len > SMALLPATH); | ||
|
||
/* Test invalid inputs */ | ||
r = uv_os_homedir(NULL, &len); | ||
ASSERT(r == UV_EINVAL); | ||
r = uv_os_homedir(homedir, NULL); | ||
ASSERT(r == UV_EINVAL); | ||
len = 0; | ||
r = uv_os_homedir(homedir, &len); | ||
ASSERT(r == UV_EINVAL); | ||
|
||
return 0; | ||
} |
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
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