Newer
Older
#ifndef ALGORITHMHISTORYTEST_H_
#define ALGORITHMHISTORYTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidAPI/AlgorithmHistory.h"
#include "MantidAPI/WorkspaceProperty.h"
using namespace Mantid::API;
class AlgorithmHistoryTest : public CxxTest::TestSuite
{
public:
void testPopulate()
{
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
std::string correctOutput = "Name : testalg\n";
correctOutput = correctOutput + "Version: version 1\n";
correctOutput = correctOutput + "Execution Date: 2008-Feb-29 09:54:49\n";
correctOutput = correctOutput + "Execution Duration: 14 seconds\n";
correctOutput = correctOutput + "Parameters:\n";
correctOutput = correctOutput + "\n";
correctOutput = correctOutput + " Name : arg1_param\n";
correctOutput = correctOutput + " Value: 20\n";
correctOutput = correctOutput + " Type: argument\n";
correctOutput = correctOutput + " isDefault: 1\n";
correctOutput = correctOutput + " Direction :Input\n";
correctOutput = correctOutput + "\n";
correctOutput = correctOutput + " Name : arg2_param\n";
correctOutput = correctOutput + " Value: 23\n";
correctOutput = correctOutput + " Type: argument\n";
correctOutput = correctOutput + " isDefault: 1\n";
correctOutput = correctOutput + " Direction :Inout\n";
//set the time
time_t rawtime;
struct tm * timeinfo;
char * weekday[] = { "Sunday", "Monday",
"Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
/* The datetime must match that in the strng above */
time ( &rawtime );
timeinfo = localtime ( &rawtime );
timeinfo->tm_year = 108;
timeinfo->tm_mon = 1;
timeinfo->tm_mday = 29;
timeinfo->tm_hour = 9;
timeinfo->tm_min = 54;
timeinfo->tm_sec = 49;
time_t execTime = mktime ( timeinfo );
// Not really much to test
std::vector<AlgorithmParameter> aps;
aps.push_back(AlgorithmParameter("arg1_param","20","argument",true,Mantid::Kernel::Direction::Input));
aps.push_back(AlgorithmParameter("arg2_param","23","argument",true,Mantid::Kernel::Direction::InOut));
AlgorithmHistory AH("testalg","version 1",execTime,14.0,aps);
//dump output to sting
std::ostringstream output;
TS_ASSERT_THROWS_NOTHING(output << AH);
TS_ASSERT_EQUALS(output.str(),correctOutput);