Electroneum
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 ()
 
virtual ~Test ()
 

Protected Attributes

const char * filename_
 
char * json_
 
size_t length_
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
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)
 
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 ()
 
 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_() {}
const char * filename_

◆ ~FileStreamTest()

FileStreamTest::~FileStreamTest ( )
virtual

Definition at line 69 of file filestreamtest.cpp.

69 {}

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  }
const char * filename_
#define ASSERT_TRUE(condition)
Definition: gtest.h:1865

◆ TearDown()

virtual void FileStreamTest::TearDown ( )
inlinevirtual

Reimplemented from testing::Test.

Definition at line 54 of file filestreamtest.cpp.

54  {
55  free(json_);
56  json_ = 0;
57  }

Member Data Documentation

◆ filename_

const char* FileStreamTest::filename_
protected

Definition at line 64 of file filestreamtest.cpp.

◆ json_

char* FileStreamTest::json_
protected

Definition at line 65 of file filestreamtest.cpp.

◆ length_

size_t FileStreamTest::length_
protected

Definition at line 66 of file filestreamtest.cpp.


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