Sha256: 9ed607c25ec53570741f0ef2d717af68b92f2e2b0546f5bab3f21e84d0c2570b

Contents?: true

Size: 954 Bytes

Versions: 7

Compression:

Stored size: 954 Bytes

Contents

#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;
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
libuv-2.0.6 ext/libuv/test/test-homedir.c
libuv-2.0.5 ext/libuv/test/test-homedir.c
libuv-2.0.4 ext/libuv/test/test-homedir.c
libuv-2.0.3 ext/libuv/test/test-homedir.c
libuv-2.0.2 ext/libuv/test/test-homedir.c
libuv-2.0.1 ext/libuv/test/test-homedir.c
libuv-2.0.0 ext/libuv/test/test-homedir.c