aboutsummaryrefslogtreecommitdiffstats
path: root/util/folder
diff options
context:
space:
mode:
authorNikita Slyusarev <nslus@yandex-team.com>2022-02-10 16:46:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:52 +0300
commitcd77cecfc03a3eaf87816af28a33067c4f0cdb59 (patch)
tree1308e0bae862d52e0020d881fe758080437fe389 /util/folder
parentcdae02d225fb5b3afbb28990e79a7ac6c9125327 (diff)
downloadydb-cd77cecfc03a3eaf87816af28a33067c4f0cdb59.tar.gz
Restoring authorship annotation for Nikita Slyusarev <nslus@yandex-team.com>. Commit 1 of 2.
Diffstat (limited to 'util/folder')
-rw-r--r--util/folder/dirut.cpp12
-rw-r--r--util/folder/dirut.h2
-rw-r--r--util/folder/dirut_ut.cpp34
-rw-r--r--util/folder/path.h8
-rw-r--r--util/folder/path_ut.cpp64
-rw-r--r--util/folder/pathsplit.cpp6
-rw-r--r--util/folder/pathsplit.h6
-rw-r--r--util/folder/pathsplit_ut.cpp556
8 files changed, 344 insertions, 344 deletions
diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp
index ffc9b09f96..793a95545b 100644
--- a/util/folder/dirut.cpp
+++ b/util/folder/dirut.cpp
@@ -563,7 +563,7 @@ int ResolvePath(const char* rel, const char* abs, char res[/*MAXPATHLEN*/], bool
*res = 0;
if (!rel || !*rel)
return EINVAL;
- if (!IsAbsolutePath(rel) && IsAbsolutePath(abs)) {
+ if (!IsAbsolutePath(rel) && IsAbsolutePath(abs)) {
len = strlcpy(t, abs, sizeof(t));
if (len >= sizeof(t) - 3)
return EINVAL;
@@ -581,13 +581,13 @@ int ResolvePath(const char* rel, const char* abs, char res[/*MAXPATHLEN*/], bool
}
if (!realpath(t, res)) {
if (!isdir && realpath(GetDirName(t).data(), res)) {
- len = strlen(res);
- if (res[len - 1] != LOCSLASH_C) {
- res[len++] = LOCSLASH_C;
- res[len] = 0;
+ len = strlen(res);
+ if (res[len - 1] != LOCSLASH_C) {
+ res[len++] = LOCSLASH_C;
+ res[len] = 0;
}
strcpy(res + len, GetBaseName(t).data());
- return 0;
+ return 0;
}
return errno ? errno : ENOENT;
}
diff --git a/util/folder/dirut.h b/util/folder/dirut.h
index 2537027b12..f7871a110a 100644
--- a/util/folder/dirut.h
+++ b/util/folder/dirut.h
@@ -67,7 +67,7 @@ inline TString GetFileNameComponent(const TString& f) {
return GetFileNameComponent(f.data());
}
-/// RealPath doesn't guarantee trailing separator to be stripped or left in place for directories.
+/// RealPath doesn't guarantee trailing separator to be stripped or left in place for directories.
TString RealPath(const TString& path); // throws
TString RealLocation(const TString& path); /// throws; last file name component doesn't need to exist
diff --git a/util/folder/dirut_ut.cpp b/util/folder/dirut_ut.cpp
index 45ebfc842c..cfe19f5482 100644
--- a/util/folder/dirut_ut.cpp
+++ b/util/folder/dirut_ut.cpp
@@ -4,8 +4,8 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/string.h>
-#include <util/memory/tempbuf.h>
-#include <util/stream/file.h>
+#include <util/memory/tempbuf.h>
+#include <util/stream/file.h>
#include <util/system/platform.h>
Y_UNIT_TEST_SUITE(TDirutTest) {
@@ -15,18 +15,18 @@ Y_UNIT_TEST_SUITE(TDirutTest) {
Y_UNIT_TEST(TestRealLocation) {
UNIT_ASSERT(IsDir(RealLocation(".")));
-
+
TTempDir tempDir;
TString base = RealPath(tempDir());
UNIT_ASSERT(!base.empty());
-
+
if (base.back() == GetDirectorySeparator()) {
base.pop_back();
}
-
+
TString path;
TString pathNotNorm;
-
+
path = base + GetDirectorySeparatorS() + "no_such_file";
UNIT_ASSERT(NFs::Exists(GetDirName(path)));
UNIT_ASSERT(!NFs::Exists(path));
@@ -34,16 +34,16 @@ Y_UNIT_TEST_SUITE(TDirutTest) {
UNIT_ASSERT(NFs::Exists(GetDirName(path)));
UNIT_ASSERT(!NFs::Exists(path));
UNIT_ASSERT_EQUAL(GetDirName(path), base);
-
+
pathNotNorm = base + GetDirectorySeparatorS() + "some_dir" + GetDirectorySeparatorS() + ".." + GetDirectorySeparatorS() + "no_such_file";
MakeDirIfNotExist((base + GetDirectorySeparatorS() + "some_dir").data());
pathNotNorm = RealLocation(pathNotNorm);
UNIT_ASSERT(NFs::Exists(GetDirName(pathNotNorm)));
UNIT_ASSERT(!NFs::Exists(pathNotNorm));
UNIT_ASSERT_EQUAL(GetDirName(pathNotNorm), base);
-
+
UNIT_ASSERT_EQUAL(path, pathNotNorm);
-
+
path = base + GetDirectorySeparatorS() + "file";
{
TFixedBufferFileOutput file(path);
@@ -55,8 +55,8 @@ Y_UNIT_TEST_SUITE(TDirutTest) {
UNIT_ASSERT(NFs::Exists(GetDirName(path)));
UNIT_ASSERT(NFs::Exists(path));
UNIT_ASSERT_EQUAL(GetDirName(path), base);
- }
-
+ }
+
void DoTest(const char* p, const char* base, const char* canon) {
TString path(p);
UNIT_ASSERT(resolvepath(path, base));
@@ -106,24 +106,24 @@ Y_UNIT_TEST_SUITE(TDirutTest) {
path = base + GetDirectorySeparatorS() + "nofile";
ResolvePath("nofile", base.data(), tempBuf.Data(), false);
UNIT_ASSERT_EQUAL(tempBuf.Data(), path);
- }
-
+ }
+
Y_UNIT_TEST(TestGetDirName) {
UNIT_ASSERT_VALUES_EQUAL(".", GetDirName("parambambam"));
- }
-
+ }
+
Y_UNIT_TEST(TestStripFileComponent) {
static const TString tmpDir = "tmp_dir_for_tests";
static const TString tmpSubDir = tmpDir + GetDirectorySeparatorS() + "subdir";
static const TString tmpFile = tmpDir + GetDirectorySeparatorS() + "file";
-
+
// creating tmp dir and subdirs
MakeDirIfNotExist(tmpDir.data());
MakeDirIfNotExist(tmpSubDir.data());
{
TFixedBufferFileOutput file(tmpFile);
}
-
+
UNIT_ASSERT_EQUAL(StripFileComponent(tmpDir), tmpDir + GetDirectorySeparatorS());
UNIT_ASSERT_EQUAL(StripFileComponent(tmpSubDir), tmpSubDir + GetDirectorySeparatorS());
UNIT_ASSERT_EQUAL(StripFileComponent(tmpFile), tmpDir + GetDirectorySeparatorS());
diff --git a/util/folder/path.h b/util/folder/path.h
index 2fb4d6b4ef..c98501fa35 100644
--- a/util/folder/path.h
+++ b/util/folder/path.h
@@ -15,10 +15,10 @@
#include <utility>
-/**
- * Class behaviour is platform-dependent.
- * It uses platform-dependent separators for path-reconstructing operations.
- */
+/**
+ * Class behaviour is platform-dependent.
+ * It uses platform-dependent separators for path-reconstructing operations.
+ */
class TFsPath {
private:
struct TSplit;
diff --git a/util/folder/path_ut.cpp b/util/folder/path_ut.cpp
index e6a3451016..7b718deabc 100644
--- a/util/folder/path_ut.cpp
+++ b/util/folder/path_ut.cpp
@@ -87,19 +87,19 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
}
Y_UNIT_TEST(Parent) {
-#ifdef _win_
+#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\etc/passwd").Parent(), TFsPath("\\etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\etc").Parent(), TFsPath("\\"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\").Parent(), TFsPath("\\"));
-
+
UNIT_ASSERT_VALUES_EQUAL(TFsPath("etc\\passwd").Parent(), TFsPath("etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("etc").Parent(), TFsPath("."));
UNIT_ASSERT_VALUES_EQUAL(TFsPath(".\\etc").Parent(), TFsPath("."));
-
+
UNIT_ASSERT_VALUES_EQUAL(TFsPath("C:\\etc/passwd").Parent(), TFsPath("C:\\etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("C:\\etc").Parent(), TFsPath("C:\\"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("C:\\").Parent(), TFsPath("C:\\"));
-#else
+#else
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/etc/passwd").Parent(), TFsPath("/etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/etc").Parent(), TFsPath("/"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/").Parent(), TFsPath("/"));
@@ -107,7 +107,7 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath("etc/passwd").Parent(), TFsPath("etc"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("etc").Parent(), TFsPath("."));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("./etc").Parent(), TFsPath("."));
-#endif
+#endif
#if 0
UNIT_ASSERT_VALUES_EQUAL(TFsPath("./etc/passwd").Parent(), TFsPath("./etc"));
@@ -194,37 +194,37 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
TFsPath p("/db/BASE/primus121-025-1380131338//");
UNIT_ASSERT_VALUES_EQUAL(p.Basename(), TString("primus121-025-1380131338"));
TFsPath testP = p / "test";
-#ifdef _win_
+#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(testP.GetPath(), "\\db\\BASE\\primus121-025-1380131338\\test");
-#else
+#else
UNIT_ASSERT_VALUES_EQUAL(testP.GetPath(), "/db/BASE/primus121-025-1380131338/test");
-#endif
+#endif
}
Y_UNIT_TEST(TestSlashesAndBasenameWin) {
- TFsPath p("\\db\\BASE\\primus121-025-1380131338\\\\");
- TFsPath testP = p / "test";
-#ifdef _win_
+ TFsPath p("\\db\\BASE\\primus121-025-1380131338\\\\");
+ TFsPath testP = p / "test";
+#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(p.Basename(), TString("primus121-025-1380131338"));
UNIT_ASSERT_VALUES_EQUAL(testP.GetPath(), "\\db\\BASE\\primus121-025-1380131338\\test");
-#else
+#else
UNIT_ASSERT_VALUES_EQUAL(p.Basename(), TString("\\db\\BASE\\primus121-025-1380131338\\\\"));
UNIT_ASSERT_VALUES_EQUAL(testP.GetPath(), "\\db\\BASE\\primus121-025-1380131338\\\\/test");
-#endif
- }
-
+#endif
+ }
+
Y_UNIT_TEST(TestSlashesAndBasenameWinDrive) {
- TFsPath p("C:\\db\\BASE\\primus121-025-1380131338\\\\");
- TFsPath testP = p / "test";
-#ifdef _win_
+ TFsPath p("C:\\db\\BASE\\primus121-025-1380131338\\\\");
+ TFsPath testP = p / "test";
+#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(p.Basename(), TString("primus121-025-1380131338"));
UNIT_ASSERT_VALUES_EQUAL(testP.GetPath(), "C:\\db\\BASE\\primus121-025-1380131338\\test");
-#else
+#else
UNIT_ASSERT_VALUES_EQUAL(p.Basename(), TString("C:\\db\\BASE\\primus121-025-1380131338\\\\"));
UNIT_ASSERT_VALUES_EQUAL(testP.GetPath(), "C:\\db\\BASE\\primus121-025-1380131338\\\\/test");
-#endif
- }
-
+#endif
+ }
+
Y_UNIT_TEST(TestList) {
TTestDirectory td("TestList-dir");
@@ -350,17 +350,17 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT_VALUES_EQUAL(TFsPath(), TFsPath().Fix());
UNIT_ASSERT_VALUES_EQUAL(TFsPath() / TFsPath(), TFsPath());
-#ifdef _win_
+#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(TFsPath("a\\b"), TFsPath() / TString("a\\b"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("a\\b"), "a\\b" / TFsPath());
UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\a\\b"), TFsPath() / "\\a\\b");
UNIT_ASSERT_VALUES_EQUAL(TFsPath("\\a\\b"), "\\a\\b" / TFsPath());
-#else
+#else
UNIT_ASSERT_VALUES_EQUAL(TFsPath("a/b"), TFsPath() / TString("a/b"));
UNIT_ASSERT_VALUES_EQUAL(TFsPath("a/b"), "a/b" / TFsPath());
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/a/b"), TFsPath() / "/a/b");
UNIT_ASSERT_VALUES_EQUAL(TFsPath("/a/b"), "/a/b" / TFsPath());
-#endif
+#endif
UNIT_ASSERT_VALUES_EQUAL(TFsPath("."), TFsPath() / ".");
UNIT_ASSERT_VALUES_EQUAL(TFsPath("."), "." / TFsPath());
@@ -380,11 +380,11 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
UNIT_ASSERT(!TFsPath().IsSubpathOf("a/b"));
UNIT_ASSERT(TFsPath().IsContainerOf("a/b"));
UNIT_ASSERT(!TFsPath().IsContainerOf("/a/b"));
-#ifdef _win_
+#ifdef _win_
UNIT_ASSERT_VALUES_EQUAL(TFsPath("a\\b").RelativeTo(TFsPath()), TFsPath("a\\b"));
-#else
+#else
UNIT_ASSERT_VALUES_EQUAL(TFsPath("a/b").RelativeTo(TFsPath()), TFsPath("a/b"));
-#endif
+#endif
UNIT_ASSERT(!TFsPath().Exists());
UNIT_ASSERT(!TFsPath().IsFile());
@@ -394,21 +394,21 @@ Y_UNIT_TEST_SUITE(TFsPathTests) {
}
Y_UNIT_TEST(TestJoinFsPaths) {
-#ifdef _win_
- UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "c\\d"), "a\\b\\c\\d");
+#ifdef _win_
+ UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "c\\d"), "a\\b\\c\\d");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", "..\\c"), "a\\b\\..\\c");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b\\..\\c", "d"), "a\\c\\d");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a", "b", "c", "d"), "a\\b\\c\\d");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b\\..\\c"), "a\\b\\..\\c");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a\\b", ""), "a\\b");
-#else
+#else
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a/b", "c/d"), "a/b/c/d");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a/b", "../c"), "a/b/../c");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a/b/../c", "d"), "a/c/d");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a", "b", "c", "d"), "a/b/c/d");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a/b/../c"), "a/b/../c");
UNIT_ASSERT_VALUES_EQUAL(JoinFsPaths("a/b", ""), "a/b");
-#endif
+#endif
}
Y_UNIT_TEST(TestStringCast) {
diff --git a/util/folder/pathsplit.cpp b/util/folder/pathsplit.cpp
index 81d439a727..d69aaf8d94 100644
--- a/util/folder/pathsplit.cpp
+++ b/util/folder/pathsplit.cpp
@@ -1,7 +1,7 @@
#include "pathsplit.h"
-#include "dirut.h"
-
+#include "dirut.h"
+
#include <util/stream/output.h>
#include <util/generic/yexception.h>
@@ -24,7 +24,7 @@ void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) {
}
if (IsAbsolutePath(part)) {
- IsAbsolute = true;
+ IsAbsolute = true;
}
DoParsePart(part);
diff --git a/util/folder/pathsplit.h b/util/folder/pathsplit.h
index d134338e35..2b734722cd 100644
--- a/util/folder/pathsplit.h
+++ b/util/folder/pathsplit.h
@@ -3,7 +3,7 @@
#include <util/generic/vector.h>
#include <util/generic/strbuf.h>
#include <util/generic/string.h>
-#include <util/string/ascii.h>
+#include <util/string/ascii.h>
//do not own any data
struct TPathSplitStore: public TVector<TStringBuf> {
@@ -23,7 +23,7 @@ protected:
struct TPathSplitTraitsUnix: public TPathSplitStore {
static constexpr char MainPathSep = '/';
-
+
inline TString Reconstruct() const {
return DoReconstruct(TStringBuf("/"));
}
@@ -42,7 +42,7 @@ struct TPathSplitTraitsUnix: public TPathSplitStore {
struct TPathSplitTraitsWindows: public TPathSplitStore {
static constexpr char MainPathSep = '\\';
-
+
inline TString Reconstruct() const {
return DoReconstruct(TStringBuf("\\"));
}
diff --git a/util/folder/pathsplit_ut.cpp b/util/folder/pathsplit_ut.cpp
index 0e97afd0d0..d48187360b 100644
--- a/util/folder/pathsplit_ut.cpp
+++ b/util/folder/pathsplit_ut.cpp
@@ -1,29 +1,29 @@
-// File includes itself to make multiple passes of its suites with different platform-dependent definitions
-
-#ifndef PS_INCLUDED
-// Outer part
-
+// File includes itself to make multiple passes of its suites with different platform-dependent definitions
+
+#ifndef PS_INCLUDED
+// Outer part
+
#include "pathsplit.h"
-
+
#include <library/cpp/testing/unittest/registar.h>
-
+
#define VAR(NAME) Y_CAT(NAME, __LINE__)
-
+
#define PS_CHECK(input, ...) \
const char* VAR(model)[] = {"", __VA_ARGS__}; \
UNIT_ASSERT_EQUAL(input.size(), sizeof(VAR(model)) / sizeof(const char*) - 1); \
for (size_t n = 0; n < input.size(); ++n) { \
UNIT_ASSERT_STRINGS_EQUAL(input[n], VAR(model)[n + 1]); \
}
-
+
#define PS_INCLUDED
-
+
#define PSUF(NAME) NAME
#define PSUF_LOCAL(NAME) NAME##Local
#include __FILE__
#undef PSUF
#undef PSUF_LOCAL
-
+
#define PSUF(NAME) NAME##Unix
#define PSUF_LOCAL(NAME) PSUF(NAME)
#ifdef _win_
@@ -37,7 +37,7 @@
#endif
#undef PSUF
#undef PSUF_LOCAL
-
+
#define PSUF(NAME) NAME##Windows
#define PSUF_LOCAL(NAME) PSUF(NAME)
#ifndef _win_
@@ -51,61 +51,61 @@
#endif
#undef PSUF
#undef PSUF_LOCAL
-
+
#undef PS_INCLUDED
-
-#else
-// Inner part
-
+
+#else
+// Inner part
+
#ifdef _win_
#define TRUE_ONLY_WIN true
#else
#define TRUE_ONLY_WIN false
#endif
-
+
Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
Y_UNIT_TEST(Empty) {
PSUF(TPathSplit)
ps;
- PS_CHECK(ps);
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
- }
-
+ PS_CHECK(ps);
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+ }
+
Y_UNIT_TEST(Relative) {
PSUF(TPathSplit)
ps("some/usual/path");
- PS_CHECK(ps, "some", "usual", "path");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
- }
-
+ PS_CHECK(ps, "some", "usual", "path");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+ }
+
Y_UNIT_TEST(Absolute) {
PSUF(TPathSplit)
ps("/some/usual/path");
- PS_CHECK(ps, "some", "usual", "path");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
- }
-
+ PS_CHECK(ps, "some", "usual", "path");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
+ }
+
Y_UNIT_TEST(Self) {
PSUF(TPathSplit)
ps(".");
- PS_CHECK(ps, ".");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
- }
-
+ PS_CHECK(ps, ".");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+ }
+
Y_UNIT_TEST(Parent) {
PSUF(TPathSplit)
ps("..");
- PS_CHECK(ps, "..");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
- }
-
+ PS_CHECK(ps, "..");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+ }
+
Y_UNIT_TEST(Root) {
PSUF(TPathSplit)
ps("/");
- PS_CHECK(ps);
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
- }
-
+ PS_CHECK(ps);
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
+ }
+
Y_UNIT_TEST(Reconstruct) {
PSUF(TPathSplit)
ps("some/usual/path/../../other/././//path");
@@ -114,369 +114,369 @@ Y_UNIT_TEST_SUITE(PSUF(PathSplit)) {
#else
UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "some/other/path");
#endif
-
+
ps = PSUF(TPathSplit)("/some/usual/path/../../other/././//path");
#ifdef _win_
UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "\\some\\other\\path");
#else
UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "/some/other/path");
#endif
- }
-
+ }
+
Y_UNIT_TEST(ParseFirstPart) {
PSUF(TPathSplit)
ps;
- ps.ParseFirstPart("some/usual/path");
- PS_CHECK(ps, "some", "usual", "path");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
-
- ps = PSUF(TPathSplit)();
- ps.ParseFirstPart("/some/usual/path");
- PS_CHECK(ps, "some", "usual", "path");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
- }
-
+ ps.ParseFirstPart("some/usual/path");
+ PS_CHECK(ps, "some", "usual", "path");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+
+ ps = PSUF(TPathSplit)();
+ ps.ParseFirstPart("/some/usual/path");
+ PS_CHECK(ps, "some", "usual", "path");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
+ }
+
Y_UNIT_TEST(ParsePart) {
PSUF(TPathSplit)
ps("some/usual/path");
- ps.ParsePart("sub/path");
- PS_CHECK(ps, "some", "usual", "path", "sub", "path");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
-
- ps = PSUF(TPathSplit)("some/usual/path");
- ps.ParsePart("/sub/path");
- PS_CHECK(ps, "some", "usual", "path", "sub", "path");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
- }
-
+ ps.ParsePart("sub/path");
+ PS_CHECK(ps, "some", "usual", "path", "sub", "path");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+
+ ps = PSUF(TPathSplit)("some/usual/path");
+ ps.ParsePart("/sub/path");
+ PS_CHECK(ps, "some", "usual", "path", "sub", "path");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+ }
+
Y_UNIT_TEST(ParsePartSelf) {
PSUF(TPathSplit)
ps("some/usual/path");
- ps.ParsePart(".");
- PS_CHECK(ps, "some", "usual", "path");
-
- ps = PSUF(TPathSplit)("some/usual/path");
- ps.ParsePart("././.");
- PS_CHECK(ps, "some", "usual", "path");
- }
-
+ ps.ParsePart(".");
+ PS_CHECK(ps, "some", "usual", "path");
+
+ ps = PSUF(TPathSplit)("some/usual/path");
+ ps.ParsePart("././.");
+ PS_CHECK(ps, "some", "usual", "path");
+ }
+
Y_UNIT_TEST(ParsePartParent) {
PSUF(TPathSplit)
ps("some/usual/path");
- ps.ParsePart("..");
- PS_CHECK(ps, "some", "usual");
-
- ps = PSUF(TPathSplit)("some/usual/path");
- ps.ParsePart("../..");
- PS_CHECK(ps, "some");
-
- ps = PSUF(TPathSplit)("some/usual/path");
- ps.ParsePart("../../..");
- PS_CHECK(ps);
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
-
- ps = PSUF(TPathSplit)("/some/usual/path");
- ps.ParsePart("../../..");
- PS_CHECK(ps);
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
- }
-
+ ps.ParsePart("..");
+ PS_CHECK(ps, "some", "usual");
+
+ ps = PSUF(TPathSplit)("some/usual/path");
+ ps.ParsePart("../..");
+ PS_CHECK(ps, "some");
+
+ ps = PSUF(TPathSplit)("some/usual/path");
+ ps.ParsePart("../../..");
+ PS_CHECK(ps);
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+
+ ps = PSUF(TPathSplit)("/some/usual/path");
+ ps.ParsePart("../../..");
+ PS_CHECK(ps);
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
+ }
+
Y_UNIT_TEST(ParsePartOverflow) {
PSUF(TPathSplit)
ps("some/usual/path");
- ps.ParsePart("../../../../..");
- PS_CHECK(ps, "..", "..");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
-
- ps = PSUF(TPathSplit)("/some/usual/path");
- ps.ParsePart("../../../../..");
- PS_CHECK(ps, "..", "..");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
- }
-
+ ps.ParsePart("../../../../..");
+ PS_CHECK(ps, "..", "..");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+
+ ps = PSUF(TPathSplit)("/some/usual/path");
+ ps.ParsePart("../../../../..");
+ PS_CHECK(ps, "..", "..");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
+ }
+
Y_UNIT_TEST(WinRelative) {
PSUF(TPathSplit)
ps("some\\usual\\path");
#ifdef _win_
- PS_CHECK(ps, "some", "usual", "path");
+ PS_CHECK(ps, "some", "usual", "path");
#else
- PS_CHECK(ps, "some\\usual\\path");
+ PS_CHECK(ps, "some\\usual\\path");
#endif
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
- }
-
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+ }
+
Y_UNIT_TEST(WinAbsolute) {
PSUF(TPathSplit)
ps("\\some\\usual\\path");
#ifdef _win_
- PS_CHECK(ps, "some", "usual", "path");
+ PS_CHECK(ps, "some", "usual", "path");
#else
- PS_CHECK(ps, "\\some\\usual\\path");
+ PS_CHECK(ps, "\\some\\usual\\path");
#endif
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, TRUE_ONLY_WIN);
-
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, TRUE_ONLY_WIN);
+
PSUF(TPathSplit)
psDrive("C:\\some\\usual\\path");
#ifdef _win_
- PS_CHECK(psDrive, "some", "usual", "path");
- UNIT_ASSERT_EQUAL(psDrive.Drive, "C:");
+ PS_CHECK(psDrive, "some", "usual", "path");
+ UNIT_ASSERT_EQUAL(psDrive.Drive, "C:");
#else
- PS_CHECK(psDrive, "C:\\some\\usual\\path");
+ PS_CHECK(psDrive, "C:\\some\\usual\\path");
#endif
- UNIT_ASSERT_EQUAL(psDrive.IsAbsolute, TRUE_ONLY_WIN);
-
+ UNIT_ASSERT_EQUAL(psDrive.IsAbsolute, TRUE_ONLY_WIN);
+
PSUF(TPathSplit)
psDrive2("C:/some/usual/path");
#ifdef _win_
- PS_CHECK(psDrive2, "some", "usual", "path");
- UNIT_ASSERT_EQUAL(psDrive2.Drive, "C:");
+ PS_CHECK(psDrive2, "some", "usual", "path");
+ UNIT_ASSERT_EQUAL(psDrive2.Drive, "C:");
#else
- PS_CHECK(psDrive2, "C:", "some", "usual", "path");
+ PS_CHECK(psDrive2, "C:", "some", "usual", "path");
#endif
- UNIT_ASSERT_EQUAL(psDrive2.IsAbsolute, TRUE_ONLY_WIN);
- }
-
+ UNIT_ASSERT_EQUAL(psDrive2.IsAbsolute, TRUE_ONLY_WIN);
+ }
+
Y_UNIT_TEST(WinRoot) {
PSUF(TPathSplit)
ps("\\");
#ifdef _win_
- PS_CHECK(ps);
+ PS_CHECK(ps);
#else
- PS_CHECK(ps, "\\");
+ PS_CHECK(ps, "\\");
#endif
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, TRUE_ONLY_WIN);
-
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, TRUE_ONLY_WIN);
+
PSUF(TPathSplit)
psDrive("C:");
#ifdef _win_
- PS_CHECK(psDrive);
- UNIT_ASSERT_EQUAL(psDrive.Drive, "C:");
+ PS_CHECK(psDrive);
+ UNIT_ASSERT_EQUAL(psDrive.Drive, "C:");
#else
- PS_CHECK(psDrive, "C:");
+ PS_CHECK(psDrive, "C:");
#endif
- UNIT_ASSERT_EQUAL(psDrive.IsAbsolute, TRUE_ONLY_WIN);
- }
-
+ UNIT_ASSERT_EQUAL(psDrive.IsAbsolute, TRUE_ONLY_WIN);
+ }
+
Y_UNIT_TEST(WinReconstruct) {
PSUF(TPathSplit)
ps("some\\usual\\path\\..\\..\\other\\.\\.\\\\\\path");
#ifdef _win_
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "some\\other\\path");
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "some\\other\\path");
#else
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "some\\usual\\path\\..\\..\\other\\.\\.\\\\\\path");
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "some\\usual\\path\\..\\..\\other\\.\\.\\\\\\path");
#endif
-
- ps = PSUF(TPathSplit)("\\some\\usual\\path\\..\\..\\other\\.\\.\\\\\\path");
+
+ ps = PSUF(TPathSplit)("\\some\\usual\\path\\..\\..\\other\\.\\.\\\\\\path");
#ifdef _win_
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "\\some\\other\\path");
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "\\some\\other\\path");
#else
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "\\some\\usual\\path\\..\\..\\other\\.\\.\\\\\\path");
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "\\some\\usual\\path\\..\\..\\other\\.\\.\\\\\\path");
#endif
- }
-
+ }
+
Y_UNIT_TEST(WinParseFirstPart) {
PSUF(TPathSplit)
ps;
- ps.ParseFirstPart("some\\usual\\path");
+ ps.ParseFirstPart("some\\usual\\path");
#ifdef _win_
- PS_CHECK(ps, "some", "usual", "path");
+ PS_CHECK(ps, "some", "usual", "path");
#else
- PS_CHECK(ps, "some\\usual\\path");
+ PS_CHECK(ps, "some\\usual\\path");
#endif
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
-
- ps = PSUF(TPathSplit)();
- ps.ParseFirstPart("\\some\\usual\\path");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+
+ ps = PSUF(TPathSplit)();
+ ps.ParseFirstPart("\\some\\usual\\path");
#ifdef _win_
- PS_CHECK(ps, "some", "usual", "path");
+ PS_CHECK(ps, "some", "usual", "path");
#else
- PS_CHECK(ps, "\\some\\usual\\path");
+ PS_CHECK(ps, "\\some\\usual\\path");
#endif
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, TRUE_ONLY_WIN);
- }
-
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, TRUE_ONLY_WIN);
+ }
+
Y_UNIT_TEST(WinParsePart) {
PSUF(TPathSplit)
ps("some\\usual\\path");
- ps.ParsePart("sub\\path");
+ ps.ParsePart("sub\\path");
#ifdef _win_
- PS_CHECK(ps, "some", "usual", "path", "sub", "path");
+ PS_CHECK(ps, "some", "usual", "path", "sub", "path");
#else
- PS_CHECK(ps, "some\\usual\\path", "sub\\path");
+ PS_CHECK(ps, "some\\usual\\path", "sub\\path");
#endif
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
-
- ps = PSUF(TPathSplit)("some\\usual\\path");
- ps.ParsePart("\\sub\\path");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+
+ ps = PSUF(TPathSplit)("some\\usual\\path");
+ ps.ParsePart("\\sub\\path");
#ifdef _win_
- PS_CHECK(ps, "some", "usual", "path", "sub", "path");
+ PS_CHECK(ps, "some", "usual", "path", "sub", "path");
#else
- PS_CHECK(ps, "some\\usual\\path", "\\sub\\path");
+ PS_CHECK(ps, "some\\usual\\path", "\\sub\\path");
#endif
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
- }
-
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+ }
+
#ifdef _win_
Y_UNIT_TEST(WinParsePartSelf) {
PSUF(TPathSplit)
ps("some\\usual\\path");
- ps.ParsePart(".");
- PS_CHECK(ps, "some", "usual", "path");
-
- ps = PSUF(TPathSplit)("some\\usual\\path");
- ps.ParsePart(".\\.\\.");
- PS_CHECK(ps, "some", "usual", "path");
- }
-
+ ps.ParsePart(".");
+ PS_CHECK(ps, "some", "usual", "path");
+
+ ps = PSUF(TPathSplit)("some\\usual\\path");
+ ps.ParsePart(".\\.\\.");
+ PS_CHECK(ps, "some", "usual", "path");
+ }
+
Y_UNIT_TEST(WinParsePartParent) {
PSUF(TPathSplit)
ps("some\\usual\\path");
- ps.ParsePart("..");
- PS_CHECK(ps, "some", "usual");
-
- ps = PSUF(TPathSplit)("some\\usual\\path");
- ps.ParsePart("..\\..");
- PS_CHECK(ps, "some");
-
- ps = PSUF(TPathSplit)("some\\usual\\path");
- ps.ParsePart("..\\..\\..");
- PS_CHECK(ps);
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
-
- ps = PSUF(TPathSplit)("\\some\\usual\\path");
- ps.ParsePart("..\\..\\..");
- PS_CHECK(ps);
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
-
- ps = PSUF(TPathSplit)("C:\\some\\usual\\path");
- ps.ParsePart("..\\..\\..");
- PS_CHECK(ps);
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
- UNIT_ASSERT_EQUAL(ps.Drive, "C:");
- }
-
+ ps.ParsePart("..");
+ PS_CHECK(ps, "some", "usual");
+
+ ps = PSUF(TPathSplit)("some\\usual\\path");
+ ps.ParsePart("..\\..");
+ PS_CHECK(ps, "some");
+
+ ps = PSUF(TPathSplit)("some\\usual\\path");
+ ps.ParsePart("..\\..\\..");
+ PS_CHECK(ps);
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+
+ ps = PSUF(TPathSplit)("\\some\\usual\\path");
+ ps.ParsePart("..\\..\\..");
+ PS_CHECK(ps);
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
+
+ ps = PSUF(TPathSplit)("C:\\some\\usual\\path");
+ ps.ParsePart("..\\..\\..");
+ PS_CHECK(ps);
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
+ UNIT_ASSERT_EQUAL(ps.Drive, "C:");
+ }
+
Y_UNIT_TEST(WinParsePartOverflow) {
PSUF(TPathSplit)
ps("some\\usual\\path");
- ps.ParsePart("..\\..\\..\\..\\..");
- PS_CHECK(ps, "..", "..");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
-
- ps = PSUF(TPathSplit)("\\some\\usual\\path");
- ps.ParsePart("..\\..\\..\\..\\..");
- PS_CHECK(ps, "..", "..");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
-
- ps = PSUF(TPathSplit)("C:\\some\\usual\\path");
- ps.ParsePart("..\\..\\..\\..\\..");
- PS_CHECK(ps, "..", "..");
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
- UNIT_ASSERT_EQUAL(ps.Drive, "C:");
- }
+ ps.ParsePart("..\\..\\..\\..\\..");
+ PS_CHECK(ps, "..", "..");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+
+ ps = PSUF(TPathSplit)("\\some\\usual\\path");
+ ps.ParsePart("..\\..\\..\\..\\..");
+ PS_CHECK(ps, "..", "..");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
+
+ ps = PSUF(TPathSplit)("C:\\some\\usual\\path");
+ ps.ParsePart("..\\..\\..\\..\\..");
+ PS_CHECK(ps, "..", "..");
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, true);
+ UNIT_ASSERT_EQUAL(ps.Drive, "C:");
+ }
#endif
-
+
Y_UNIT_TEST(WinMixed) {
PSUF(TPathSplit)
ps("some\\usual/path");
#ifdef _win_
- PS_CHECK(ps, "some", "usual", "path");
+ PS_CHECK(ps, "some", "usual", "path");
#else
- PS_CHECK(ps, "some\\usual", "path");
+ PS_CHECK(ps, "some\\usual", "path");
#endif
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
- }
-
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+ }
+
Y_UNIT_TEST(WinParsePartMixed) {
PSUF(TPathSplit)
ps("some\\usual/path");
- ps.ParsePart("sub/sub\\path");
+ ps.ParsePart("sub/sub\\path");
#ifdef _win_
- PS_CHECK(ps, "some", "usual", "path", "sub", "sub", "path");
+ PS_CHECK(ps, "some", "usual", "path", "sub", "sub", "path");
#else
- PS_CHECK(ps, "some\\usual", "path", "sub", "sub\\path");
+ PS_CHECK(ps, "some\\usual", "path", "sub", "sub\\path");
#endif
- UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
- }
-
+ UNIT_ASSERT_EQUAL(ps.IsAbsolute, false);
+ }
+
Y_UNIT_TEST(BeginWithSelf) {
PSUF(TPathSplit)
ps("./some/usual/path");
- PS_CHECK(ps, "some", "usual", "path");
+ PS_CHECK(ps, "some", "usual", "path");
#ifdef _win_
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "some\\usual\\path");
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "some\\usual\\path");
#else
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "some/usual/path");
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "some/usual/path");
#endif
- }
-
+ }
+
Y_UNIT_TEST(BeginWithParent) {
PSUF(TPathSplit)
ps("../some/usual/path");
- PS_CHECK(ps, "..", "some", "usual", "path");
+ PS_CHECK(ps, "..", "some", "usual", "path");
#ifdef _win_
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "..\\some\\usual\\path");
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "..\\some\\usual\\path");
#else
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "../some/usual/path");
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "../some/usual/path");
#endif
- }
-
+ }
+
Y_UNIT_TEST(InOut) {
PSUF(TPathSplit)
ps("path/..");
- PS_CHECK(ps);
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "");
- }
-
+ PS_CHECK(ps);
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "");
+ }
+
Y_UNIT_TEST(OutIn) {
PSUF(TPathSplit)
ps("../path");
- PS_CHECK(ps, "..", "path");
+ PS_CHECK(ps, "..", "path");
#ifdef _win_
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "..\\path");
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "..\\path");
#else
- UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "../path");
+ UNIT_ASSERT_STRINGS_EQUAL(ps.Reconstruct(), "../path");
#endif
- }
-}
-
+ }
+}
+
Y_UNIT_TEST_SUITE(PSUF(PathSplitTraits)) {
Y_UNIT_TEST(IsPathSep) {
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep('/'), true);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep('\\'), TRUE_ONLY_WIN);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep(' '), false);
- }
-
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep('/'), true);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep('\\'), TRUE_ONLY_WIN);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsPathSep(' '), false);
+ }
+
Y_UNIT_TEST(IsAbsolutePath) {
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath(""), false);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/"), true);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("some/usual/path"), false);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/some/usual/path"), true);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("."), false);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath(".."), false);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/."), true);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/.."), true);
- }
-
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath(""), false);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/"), true);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("some/usual/path"), false);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/some/usual/path"), true);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("."), false);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath(".."), false);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/."), true);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("/.."), true);
+ }
+
Y_UNIT_TEST(WinIsAbsolutePath) {
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("somepath"), false);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\"), TRUE_ONLY_WIN);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\somepath"), TRUE_ONLY_WIN);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\."), TRUE_ONLY_WIN);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\.."), TRUE_ONLY_WIN);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C"), false);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:"), TRUE_ONLY_WIN);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:somepath"), false);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:\\"), TRUE_ONLY_WIN);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:\\somepath"), TRUE_ONLY_WIN);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:/"), TRUE_ONLY_WIN);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:/somepath"), TRUE_ONLY_WIN);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("#:"), false);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("#:somepath"), false);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("#:\\somepath"), false);
- UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("#:/somepath"), false);
- }
-}
-
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("somepath"), false);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\"), TRUE_ONLY_WIN);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\somepath"), TRUE_ONLY_WIN);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\."), TRUE_ONLY_WIN);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("\\.."), TRUE_ONLY_WIN);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C"), false);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:"), TRUE_ONLY_WIN);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:somepath"), false);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:\\"), TRUE_ONLY_WIN);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:\\somepath"), TRUE_ONLY_WIN);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:/"), TRUE_ONLY_WIN);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("C:/somepath"), TRUE_ONLY_WIN);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("#:"), false);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("#:somepath"), false);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("#:\\somepath"), false);
+ UNIT_ASSERT_EQUAL(PSUF_LOCAL(TPathSplitTraits)::IsAbsolutePath("#:/somepath"), false);
+ }
+}
+
#undef TRUE_ONLY_WIN
-
-#endif
+
+#endif