diff options
author | Alexander Fokin <apfokin@gmail.com> | 2022-02-10 16:45:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:38 +0300 |
commit | 863a59a65247c24db7cb06789bc5cf79d04da32f (patch) | |
tree | 139dc000c8cd4a40f5659e421b7c75135d080307 /util/stream/file_ut.cpp | |
parent | f64e95a9eb9ab03240599eb9581c5a9102426a96 (diff) | |
download | ydb-863a59a65247c24db7cb06789bc5cf79d04da32f.tar.gz |
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/stream/file_ut.cpp')
-rw-r--r-- | util/stream/file_ut.cpp | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/util/stream/file_ut.cpp b/util/stream/file_ut.cpp index ac0f09796e..1ed0beb1e5 100644 --- a/util/stream/file_ut.cpp +++ b/util/stream/file_ut.cpp @@ -1,61 +1,61 @@ -#include "file.h" - +#include "file.h" + #include <library/cpp/testing/unittest/registar.h> - -#include <util/system/tempfile.h> - -static const char* TmpFileName = "./fileio"; -static const char* TmpFileContents = "To do good to Mankind is the chivalrous plan"; -static const char* TmpFileSubstring = strstr(TmpFileContents, "chivalrous"); - + +#include <util/system/tempfile.h> + +static const char* TmpFileName = "./fileio"; +static const char* TmpFileContents = "To do good to Mankind is the chivalrous plan"; +static const char* TmpFileSubstring = strstr(TmpFileContents, "chivalrous"); + Y_UNIT_TEST_SUITE(TFileTest) { Y_UNIT_TEST(InputTest) { - TTempFile tmp(TmpFileName); - - { + TTempFile tmp(TmpFileName); + + { TUnbufferedFileOutput output(TmpFileName); - output.Write(TmpFileContents, strlen(TmpFileContents)); - } - - { + output.Write(TmpFileContents, strlen(TmpFileContents)); + } + + { TUnbufferedFileInput input(TmpFileName); TString s = input.ReadAll(); - UNIT_ASSERT_VALUES_EQUAL(s, TmpFileContents); - } - - { + UNIT_ASSERT_VALUES_EQUAL(s, TmpFileContents); + } + + { TUnbufferedFileInput input(TmpFileName); - input.Skip(TmpFileSubstring - TmpFileContents); + input.Skip(TmpFileSubstring - TmpFileContents); TString s = input.ReadAll(); - UNIT_ASSERT_VALUES_EQUAL(s, "chivalrous plan"); - } - - { + UNIT_ASSERT_VALUES_EQUAL(s, "chivalrous plan"); + } + + { TUnbufferedFileOutput output(TFile::ForAppend(TmpFileName)); - output.Write(TmpFileContents, strlen(TmpFileContents)); - } - - { + output.Write(TmpFileContents, strlen(TmpFileContents)); + } + + { TUnbufferedFileInput input(TmpFileName); TString s = input.ReadAll(); UNIT_ASSERT_VALUES_EQUAL(s, TString::Join(TmpFileContents, TmpFileContents)); - } - } - + } + } + Y_UNIT_TEST(EmptyMapTest) { - TTempFile tmp(TmpFileName); - - { + TTempFile tmp(TmpFileName); + + { TUnbufferedFileOutput output(TmpFileName); - /* Write nothing. */ - } - - { - TMappedFileInput input(TmpFileName); + /* Write nothing. */ + } + + { + TMappedFileInput input(TmpFileName); TString s = input.ReadAll(); - UNIT_ASSERT(s.empty()); - } - } + UNIT_ASSERT(s.empty()); + } + } #ifdef _unix_ Y_UNIT_TEST(PipeReadLineTest) { @@ -71,4 +71,4 @@ Y_UNIT_TEST_SUITE(TFileTest) { close(fds[1]); } #endif -} +} |