Skip to content

Commit 75cf9c3

Browse files
committed
Rewrite is_open functions
1 parent ec31b21 commit 75cf9c3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/file.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ namespace {
2828
/// Test fixture for `basic_file` tests
2929
template<class charT> class file : public testing::Test {
3030
public:
31-
/// Returns whether the underlying raw file device object is open
32-
bool is_open(const basic_file<charT>& file) {
33-
auto filebuf = dynamic_cast<std::basic_filebuf<charT>*>(file.rdbuf());
31+
/// Returns whether the file device object is open
32+
bool is_open(const std::basic_streambuf<charT>* streambuf) {
33+
auto filebuf = dynamic_cast<const std::basic_filebuf<charT>*>(streambuf);
3434
return filebuf != nullptr && filebuf->is_open();
3535
}
3636

37-
/// Checks if the given file handle is valid
37+
/// Returns whether the given file handle is open
3838
bool is_open(typename basic_file<charT>::native_handle_type handle) {
3939
#ifdef _WIN32
4040
BY_HANDLE_FILE_INFORMATION info;
@@ -83,7 +83,7 @@ TYPED_TEST(file, type_traits) {
8383
/// Tests file creation
8484
TYPED_TEST(file, create) {
8585
basic_file<TypeParam> tmpfile = basic_file<TypeParam>();
86-
EXPECT_TRUE(TestFixture::is_open(tmpfile));
86+
EXPECT_TRUE(TestFixture::is_open(tmpfile.rdbuf()));
8787
EXPECT_TRUE(TestFixture::is_open(tmpfile.native_handle()));
8888
}
8989

@@ -126,7 +126,7 @@ TYPED_TEST(file, move_constructor) {
126126

127127
basic_file<TypeParam> snd = basic_file<TypeParam>(std::move(fst));
128128

129-
EXPECT_TRUE(TestFixture::is_open(snd));
129+
EXPECT_TRUE(TestFixture::is_open(snd.rdbuf()));
130130

131131
snd.seekg(0);
132132
std::basic_string<TypeParam> content;
@@ -152,7 +152,7 @@ TYPED_TEST(file, move_assignment) {
152152
EXPECT_EQ(fst.native_handle(), snd_handle);
153153
}
154154

155-
EXPECT_TRUE(TestFixture::is_open(fst));
155+
EXPECT_TRUE(TestFixture::is_open(fst.rdbuf()));
156156

157157
fst.seekg(0);
158158
std::basic_string<TypeParam> content;
@@ -172,8 +172,8 @@ TYPED_TEST(file, swap) {
172172

173173
EXPECT_EQ(fst.native_handle(), snd_handle);
174174
EXPECT_EQ(snd.native_handle(), fst_handle);
175-
EXPECT_TRUE(TestFixture::is_open(fst));
176-
EXPECT_TRUE(TestFixture::is_open(snd));
175+
EXPECT_TRUE(TestFixture::is_open(fst.rdbuf()));
176+
EXPECT_TRUE(TestFixture::is_open(snd.rdbuf()));
177177
}
178178
} // namespace
179179
} // namespace tmp

0 commit comments

Comments
 (0)