Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef SAVENISTDATTEST_H_
#define SAVENISTDATTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidDataHandling/Load.h"
#include "MantidDataHandling/SaveNISTDAT.h"
#include <Poco/File.h>
#include <fstream>
using namespace Mantid::API;
using namespace Mantid::DataHandling;
class SaveNISTDATTest : public CxxTest::TestSuite
{
public:
void test_writer()
{
std::string outputFile = "SaveNISTDAT_Output.dat";
Load loader;
loader.initialize();
TS_ASSERT_THROWS_NOTHING(loader.setPropertyValue("Filename", "saveNISTDAT_data.nxs"));
loader.setPropertyValue("OutputWorkspace","SaveNISTDAT_Input");
TS_ASSERT_THROWS_NOTHING(loader.execute());
SaveNISTDAT writer;
writer.initialize();
writer.setPropertyValue("InputWorkspace","SaveNISTDAT_Input");
writer.setPropertyValue("Filename",outputFile);
outputFile = writer.getPropertyValue("Filename");
TS_ASSERT_THROWS_NOTHING(writer.execute());
TS_ASSERT( Poco::File(outputFile).exists() );
std::ifstream testFile(outputFile.c_str(), std::ios::in);
TS_ASSERT ( testFile );
std::string fileLine;
std::getline( testFile, fileLine );
TS_ASSERT_EQUALS ( fileLine, "Qx - Qy - I(Qx,Qy) - dI(Qx,Qy)\r" );
std::getline( testFile, fileLine );
TS_ASSERT_EQUALS ( fileLine, "ASCII data\r" );
std::getline( testFile, fileLine );
TS_ASSERT_EQUALS ( fileLine, "-0.0105 -0.0735 6.13876e+08 6.1697e+07\r" );
Gigg, Martyn Anthony
committed
// remove file created by this algorithm, closing it first as Windows gets tetchy about this
testFile.close();
Poco::File(outputFile).remove();
}
};
#endif /*SAVENISTDATTEST_H_*/