Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
FileStreamTest Class Reference
Inheritance diagram for FileStreamTest:
Collaboration diagram for FileStreamTest:

Public Member Functions

 FileStreamTest ()
 
virtual ~FileStreamTest ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 

Protected Attributes

const char * filename_
 
char * json_
 
size_t length_
 
const char * abcde_
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
- Protected Member Functions inherited from testing::Test
 Test ()
 

Detailed Description

Definition at line 22 of file filestreamtest.cpp.

Constructor & Destructor Documentation

◆ FileStreamTest()

FileStreamTest::FileStreamTest ( )
inline

Definition at line 24 of file filestreamtest.cpp.

24: filename_(), json_(), length_(), abcde_() {}
const char * abcde_
const char * filename_

◆ ~FileStreamTest()

FileStreamTest::~FileStreamTest ( )
virtual

Definition at line 88 of file filestreamtest.cpp.

88{}

Member Function Documentation

◆ SetUp()

virtual void FileStreamTest::SetUp ( )
inlinevirtual

Reimplemented from testing::Test.

Definition at line 27 of file filestreamtest.cpp.

27 {
28 const char *paths[] = {
29 "data/sample.json",
30 "bin/data/sample.json",
31 "../bin/data/sample.json",
32 "../../bin/data/sample.json",
33 "../../../bin/data/sample.json"
34 };
35 FILE* fp = 0;
36 for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
37 fp = fopen(paths[i], "rb");
38 if (fp) {
39 filename_ = paths[i];
40 break;
41 }
42 }
43 ASSERT_TRUE(fp != 0);
44
45 fseek(fp, 0, SEEK_END);
46 length_ = static_cast<size_t>(ftell(fp));
47 fseek(fp, 0, SEEK_SET);
48 json_ = static_cast<char*>(malloc(length_ + 1));
49 size_t readLength = fread(json_, 1, length_, fp);
50 json_[readLength] = '\0';
51 fclose(fp);
52
53 const char *abcde_paths[] = {
54 "data/abcde.txt",
55 "bin/data/abcde.txt",
56 "../bin/data/abcde.txt",
57 "../../bin/data/abcde.txt",
58 "../../../bin/data/abcde.txt"
59 };
60 fp = 0;
61 for (size_t i = 0; i < sizeof(abcde_paths) / sizeof(abcde_paths[0]); i++) {
62 fp = fopen(abcde_paths[i], "rb");
63 if (fp) {
64 abcde_ = abcde_paths[i];
65 break;
66 }
67 }
68 ASSERT_TRUE(fp != 0);
69 fclose(fp);
70 }
#define ASSERT_TRUE(condition)
Definition gtest.h:1901

◆ TearDown()

virtual void FileStreamTest::TearDown ( )
inlinevirtual

Reimplemented from testing::Test.

Definition at line 72 of file filestreamtest.cpp.

72 {
73 free(json_);
74 json_ = 0;
75 }

Member Data Documentation

◆ abcde_

const char* FileStreamTest::abcde_
protected

Definition at line 85 of file filestreamtest.cpp.

◆ filename_

const char* FileStreamTest::filename_
protected

Definition at line 82 of file filestreamtest.cpp.

◆ json_

char* FileStreamTest::json_
protected

Definition at line 83 of file filestreamtest.cpp.

◆ length_

size_t FileStreamTest::length_
protected

Definition at line 84 of file filestreamtest.cpp.


The documentation for this class was generated from the following file: