|
| static FILE * | Open (const char *filename) |
| |
| static char * | ReadFile (const char *filename, bool appendPath, size_t *outLength) |
| |
Definition at line 25 of file encodedstreamtest.cpp.
◆ EncodedStreamTest()
| EncodedStreamTest::EncodedStreamTest |
( |
| ) |
|
|
inline |
◆ ~EncodedStreamTest()
| EncodedStreamTest::~EncodedStreamTest |
( |
| ) |
|
|
virtual |
◆ CompareBufferFile()
| bool EncodedStreamTest::CompareBufferFile |
( |
const char * |
actualBuffer, |
|
|
size_t |
actualLength, |
|
|
const char * |
expectedFilename |
|
) |
| |
|
inlineprotected |
Definition at line 240 of file encodedstreamtest.cpp.
241 size_t expectedLength;
242 char* expectedBuffer =
ReadFile(expectedFilename,
true, &expectedLength);
243 bool ret = (expectedLength == actualLength) && memcmp(expectedBuffer, actualBuffer, actualLength) == 0;
244 free(expectedBuffer);
static char * ReadFile(const char *filename, bool appendPath, size_t *outLength)
◆ CompareFile()
| bool EncodedStreamTest::CompareFile |
( |
const char * |
filename, |
|
|
const char * |
expectedFilename |
|
) |
| |
|
inlineprotected |
Definition at line 230 of file encodedstreamtest.cpp.
231 size_t actualLength, expectedLength;
232 char* actualBuffer =
ReadFile(filename,
false, &actualLength);
233 char* expectedBuffer =
ReadFile(expectedFilename,
true, &expectedLength);
234 bool ret = (expectedLength == actualLength) && memcmp(expectedBuffer, actualBuffer, actualLength) == 0;
236 free(expectedBuffer);
static char * ReadFile(const char *filename, bool appendPath, size_t *outLength)
◆ Open()
| static FILE* EncodedStreamTest::Open |
( |
const char * |
filename | ) |
|
|
inlinestaticprotected |
Definition at line 44 of file encodedstreamtest.cpp.
45 const char *paths[] = {
49 "../../bin/encodings",
50 "../../../bin/encodings" 53 for (
size_t i = 0; i <
sizeof(paths) /
sizeof(paths[0]); i++) {
54 sprintf(buffer,
"%s/%s", paths[i], filename);
55 FILE *fp = fopen(buffer,
"rb");
◆ ReadFile()
| static char* EncodedStreamTest::ReadFile |
( |
const char * |
filename, |
|
|
bool |
appendPath, |
|
|
size_t * |
outLength |
|
) |
| |
|
inlinestaticprotected |
Definition at line 62 of file encodedstreamtest.cpp.
63 FILE *fp = appendPath ?
Open(filename) : fopen(filename,
"rb");
70 fseek(fp, 0, SEEK_END);
71 *outLength =
static_cast<size_t>(ftell(fp));
72 fseek(fp, 0, SEEK_SET);
73 char* buffer =
static_cast<char*
>(malloc(*outLength + 1));
74 size_t readLength = fread(buffer, 1, *outLength, fp);
75 buffer[readLength] =
'\0';
static FILE * Open(const char *filename)
◆ SetUp()
| virtual void EncodedStreamTest::SetUp |
( |
| ) |
|
|
inlinevirtual |
◆ TearDown()
| virtual void EncodedStreamTest::TearDown |
( |
| ) |
|
|
inlinevirtual |
◆ TestAutoUTFInputStream()
| void EncodedStreamTest::TestAutoUTFInputStream |
( |
const char * |
filename, |
|
|
bool |
expectHasBOM |
|
) |
| |
|
inlineprotected |
Definition at line 121 of file encodedstreamtest.cpp.
125 FILE *fp =
Open(filename);
131 while (eis.Peek() !=
'\0') {
132 unsigned expected, actual;
144 char* data =
ReadFile(filename,
true, &size);
150 while (eis.Peek() !=
'\0') {
151 unsigned expected, actual;
#define EXPECT_TRUE(condition)
Represents an in-memory input byte stream.
File byte stream for input using fread().
Dynamically select encoding according to stream's runtime-specified UTF encoding type.
#define ASSERT_TRUE(condition)
static FILE * Open(const char *filename)
#define EXPECT_EQ(val1, val2)
static char * ReadFile(const char *filename, bool appendPath, size_t *outLength)
◆ TestAutoUTFOutputStream()
| void EncodedStreamTest::TestAutoUTFOutputStream |
( |
UTFType |
type, |
|
|
bool |
putBOM, |
|
|
const char * |
expectedFilename |
|
) |
| |
|
inlineprotected |
Definition at line 196 of file encodedstreamtest.cpp.
199 char filename[L_tmpnam];
206 while (s.Peek() !=
'\0') {
221 while (s.Peek() !=
'\0') {
#define EXPECT_TRUE(condition)
FILE * TempFile(char *filename)
bool CompareBufferFile(const char *actualBuffer, size_t actualLength, const char *expectedFilename)
bool CompareFile(const char *filename, const char *expectedFilename)
Represents an in-memory output byte stream.
Output stream wrapper with dynamically bound encoding and automatic encoding detection.
expect< void > success() noexcept
const Ch * GetBuffer() const
Wrapper of C file stream for output using fwrite().
◆ TestEncodedInputStream()
template<typename FileEncoding , typename MemoryEncoding >
| void EncodedStreamTest::TestEncodedInputStream |
( |
const char * |
filename | ) |
|
|
inlineprotected |
Definition at line 81 of file encodedstreamtest.cpp.
85 FILE *fp =
Open(filename);
91 while (eis.Peek() !=
'\0') {
92 unsigned expected, actual;
104 char* data =
ReadFile(filename,
true, &size);
109 while (eis.Peek() !=
'\0') {
110 unsigned expected, actual;
#define EXPECT_TRUE(condition)
Represents an in-memory input byte stream.
File byte stream for input using fread().
#define ASSERT_TRUE(condition)
static FILE * Open(const char *filename)
#define EXPECT_EQ(val1, val2)
static char * ReadFile(const char *filename, bool appendPath, size_t *outLength)
◆ TestEncodedOutputStream()
template<typename FileEncoding , typename MemoryEncoding >
| void EncodedStreamTest::TestEncodedOutputStream |
( |
const char * |
expectedFilename, |
|
|
bool |
putBOM |
|
) |
| |
|
inlineprotected |
Definition at line 163 of file encodedstreamtest.cpp.
166 char filename[L_tmpnam];
172 while (s.Peek() !=
'\0') {
187 while (s.Peek() !=
'\0') {
#define EXPECT_TRUE(condition)
Output byte stream wrapper with statically bound encoding.
FILE * TempFile(char *filename)
bool CompareBufferFile(const char *actualBuffer, size_t actualLength, const char *expectedFilename)
bool CompareFile(const char *filename, const char *expectedFilename)
Represents an in-memory output byte stream.
expect< void > success() noexcept
const Ch * GetBuffer() const
Wrapper of C file stream for output using fwrite().
◆ json_
| char* EncodedStreamTest::json_ |
|
protected |
◆ length_
| size_t EncodedStreamTest::length_ |
|
protected |
The documentation for this class was generated from the following file: