fix: fix unfinished u8 fopen.
- finish unfinished utf8 version fopen. - add testbench for it.
This commit is contained in:
@ -11,6 +11,7 @@ PRIVATE
|
||||
yycc/constraint.cpp
|
||||
yycc/constraint/builder.cpp
|
||||
yycc/patch/ptr_pad.cpp
|
||||
yycc/patch/fopen.cpp
|
||||
yycc/string/op.cpp
|
||||
yycc/string/reinterpret.cpp
|
||||
yycc/num/parse.cpp
|
||||
|
24
testbench/yycc/patch/fopen.cpp
Normal file
24
testbench/yycc/patch/fopen.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <yycc.hpp>
|
||||
#include <yycc/patch/fopen.hpp>
|
||||
|
||||
#define FOPEN ::yycc::patch::fopen
|
||||
|
||||
namespace yycctest::patch::fopen {
|
||||
|
||||
TEST(PatchFopen, Normal) {
|
||||
FILE* handle;
|
||||
|
||||
#if defined(YYCC_OS_WINDOWS)
|
||||
// In Windows, we can always visit NUL device.
|
||||
handle = FOPEN::fopen(u8"NUL", u8"wb");
|
||||
#else
|
||||
// In other system following UNIX design, we can visit /dev/null device.
|
||||
handle = FOPEN::fopen(u8"/dev/null", u8"wb");
|
||||
#endif
|
||||
|
||||
ASSERT_TRUE(handle != nullptr);
|
||||
std::fclose(handle);
|
||||
}
|
||||
|
||||
} // namespace yycctest::patch::fopen
|
Reference in New Issue
Block a user