PSCF v1.1
ParamFileTest.h
1#ifndef PARAM_FILE_TEST_H
2#define PARAM_FILE_TEST_H
3
4#include "UnitTest.h"
5
6#include <string>
7#include <iostream>
8#include <fstream>
9
15class ParamFileTest : public UnitTest
16{
17
18public:
19
24 : UnitTest()
25 {}
26
31 { closeFile(); }
32
36 virtual void tearDown()
37 { closeFile(); }
38
42 void openFile(const char *fileName)
43 {
44 if (isIoProcessor()) {
45 openInputFile(std::string(fileName), file_);
46 }
47 }
48
52 void closeFile()
53 { if (file_.is_open()) file_.close(); }
54
58 std::ifstream& file()
59 { return file_; }
60
61private:
62
63 std::ifstream file_;
64
65};
66
67#endif
A UnitTest with a built-in input file.
Definition: ParamFileTest.h:16
~ParamFileTest()
Destructor.
Definition: ParamFileTest.h:30
virtual void tearDown()
Close the input file.
Definition: ParamFileTest.h:36
std::ifstream & file()
Returns input file by reference.
Definition: ParamFileTest.h:58
void openFile(const char *fileName)
Open the input file.
Definition: ParamFileTest.h:42
ParamFileTest()
Constructor.
Definition: ParamFileTest.h:23
void closeFile()
Close the input file.
Definition: ParamFileTest.h:52
UnitTest is a base class for classes that define unit tests.
Definition: UnitTest.h:51
void openInputFile(const std::string &name, std::ifstream &in) const
Open C++ input file ifstream.
Definition: UnitTest.h:343
bool isIoProcessor() const
Should this processor read and write to file?
Definition: UnitTest.h:274