aboutsummaryrefslogtreecommitdiffstats
path: root/util/folder/dirut_ut.cpp
diff options
context:
space:
mode:
authorNikita Slyusarev <nslus@yandex-team.com>2022-02-10 16:46:53 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:53 +0300
commit469afdc4e2587bf62ecdd096b75a0baa444c4012 (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /util/folder/dirut_ut.cpp
parentcd77cecfc03a3eaf87816af28a33067c4f0cdb59 (diff)
downloadydb-469afdc4e2587bf62ecdd096b75a0baa444c4012.tar.gz
Restoring authorship annotation for Nikita Slyusarev <nslus@yandex-team.com>. Commit 2 of 2.
Diffstat (limited to 'util/folder/dirut_ut.cpp')
-rw-r--r--util/folder/dirut_ut.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/util/folder/dirut_ut.cpp b/util/folder/dirut_ut.cpp
index cfe19f5482..45ebfc842c 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());