aboutsummaryrefslogtreecommitdiffstats
path: root/util/folder/fts_ut.cpp
diff options
context:
space:
mode:
authorkaliki <kaliki@yandex-team.ru>2022-02-10 16:48:06 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:06 +0300
commita79404df3a1d90f4b37ac8a1ce0a2bfb5dfd06f1 (patch)
tree3302aab790ee7891a6ed0b4b9257ab4dd02ae4c1 /util/folder/fts_ut.cpp
parentb552921bb1c7ea535f6e0e1706feb311c27d6036 (diff)
downloadydb-a79404df3a1d90f4b37ac8a1ce0a2bfb5dfd06f1.tar.gz
Restoring authorship annotation for <kaliki@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/folder/fts_ut.cpp')
-rw-r--r--util/folder/fts_ut.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/util/folder/fts_ut.cpp b/util/folder/fts_ut.cpp
index c5d59e35f4..51882b2317 100644
--- a/util/folder/fts_ut.cpp
+++ b/util/folder/fts_ut.cpp
@@ -4,60 +4,60 @@
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/threading/future/async.h>
-
+
#include <util/system/file.h>
#include <util/system/tempfile.h>
#include <util/generic/string.h>
-
-class TFtsTest: public TTestBase {
+
+class TFtsTest: public TTestBase {
UNIT_TEST_SUITE(TFtsTest);
UNIT_TEST(TestSimple);
UNIT_TEST(TestNoLeakChangingAccessToFolder);
UNIT_TEST_SUITE_END();
-
+
public:
void TestSimple();
void TestNoLeakChangingAccessToFolder();
-};
-
+};
+
void MakeFile(const char* path) {
TFile(path, CreateAlways);
-}
-
-//There potentially could be problems in listing order on different platforms
+}
+
+//There potentially could be problems in listing order on different platforms
int FtsCmp(const FTSENT** ent1, const FTSENT** ent2) {
- return strcmp((*ent1)->fts_accpath, (*ent2)->fts_accpath);
-}
-
+ return strcmp((*ent1)->fts_accpath, (*ent2)->fts_accpath);
+}
+
void CheckEnt(FTSENT* ent, const char* name, int type) {
- UNIT_ASSERT(ent);
- UNIT_ASSERT_STRINGS_EQUAL(ent->fts_path, name);
- UNIT_ASSERT_EQUAL(ent->fts_info, type);
-}
-
+ UNIT_ASSERT(ent);
+ UNIT_ASSERT_STRINGS_EQUAL(ent->fts_path, name);
+ UNIT_ASSERT_EQUAL(ent->fts_info, type);
+}
+
class TFileTree {
-public:
+public:
TFileTree(char* const* argv, int options, int (*compar)(const FTSENT**, const FTSENT**)) {
Fts_ = yfts_open(argv, options, compar);
- }
-
+ }
+
~TFileTree() {
yfts_close(Fts_);
- }
-
- FTS* operator()() {
+ }
+
+ FTS* operator()() {
return Fts_;
- }
+ }
-private:
+private:
FTS* Fts_;
-};
-
+};
+
void TFtsTest::TestSimple() {
const char* dotPath[2] = {"." LOCSLASH_S, nullptr};
TFileTree currentDirTree((char* const*)dotPath, 0, FtsCmp);
- UNIT_ASSERT(currentDirTree());
- TTempDir tempDir = MakeTempName(yfts_read(currentDirTree())->fts_path);
+ UNIT_ASSERT(currentDirTree());
+ TTempDir tempDir = MakeTempName(yfts_read(currentDirTree())->fts_path);
MakeDirIfNotExist(tempDir().data());
MakeDirIfNotExist((tempDir() + LOCSLASH_S "dir1").data());
MakeFile((tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file1").data());
@@ -65,10 +65,10 @@ void TFtsTest::TestSimple() {
MakeDirIfNotExist((tempDir() + LOCSLASH_S "dir2").data());
MakeFile((tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file3").data());
MakeFile((tempDir() + LOCSLASH_S "dir2" LOCSLASH_S "file4").data());
-
+
const char* path[2] = {tempDir().data(), nullptr};
TFileTree fileTree((char* const*)path, 0, FtsCmp);
- UNIT_ASSERT(fileTree());
+ UNIT_ASSERT(fileTree());
CheckEnt(yfts_read(fileTree()), tempDir().data(), FTS_D);
CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1").data(), FTS_D);
CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir1" LOCSLASH_S "file1").data(), FTS_F);
@@ -80,8 +80,8 @@ void TFtsTest::TestSimple() {
CheckEnt(yfts_read(fileTree()), (tempDir() + LOCSLASH_S "dir2").data(), FTS_DP);
CheckEnt(yfts_read(fileTree()), (tempDir()).data(), FTS_DP);
UNIT_ASSERT_EQUAL(yfts_read(fileTree()), nullptr);
-}
-
+}
+
class TTempDirWithLostAccess: public TTempDir {
public:
~TTempDirWithLostAccess() {