tests: fs/FileReq/RWSync

This commit is contained in:
Michele Caini 2016-11-07 12:39:33 +01:00
parent 6ec8195fd3
commit e32860e2b5

View File

@ -104,12 +104,36 @@ TEST(FileReq, RW) {
}
/*
TEST(FileReq, RWSync) {
// TODO
const std::string filename = std::string{TARGET_FS_DIR} + std::string{"/test.fs"};
auto loop = uvw::Loop::getDefault();
auto request = loop->resource<uvw::FileReq>();
#ifdef _WIN32
request->openSync(filename, _O_CREAT | _O_RDWR | _O_TRUNC, 0644);
#else
request->openSync(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
#endif
auto writeR = request->writeSync(std::unique_ptr<char[]>{new char[1]{ 42 }}, 1, 0);
ASSERT_TRUE(writeR.first);
ASSERT_EQ(writeR.second, 1);
auto readR = request->readSync(0, 1);
ASSERT_TRUE(readR.first);
ASSERT_EQ(readR.second.first[0], 42);
ASSERT_EQ(readR.second.second, 1);
ASSERT_TRUE(request->closeSync());
loop->run();
}
/*
TEST(FileReq, Stat) {
// TODO
}