Skip to content
Snippets Groups Projects
AlgorithmHistoryTest.h 2.37 KiB
Newer Older
Dickon Champion's avatar
Dickon Champion committed
#ifndef ALGORITHMHISTORYTEST_H_
#define ALGORITHMHISTORYTEST_H_

#include <cxxtest/TestSuite.h>
#include "MantidAPI/AlgorithmHistory.h"
#include "MantidAPI/WorkspaceProperty.h"
Nick Draper's avatar
Nick Draper committed
#include <sstream>
Dickon Champion's avatar
Dickon Champion committed

using namespace Mantid::API;



class AlgorithmHistoryTest : public CxxTest::TestSuite
{
public:

  void testPopulate()
  {
Nick Draper's avatar
Nick Draper committed
    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 );

Dickon Champion's avatar
Dickon Champion committed
    // Not really much to test
    std::vector<AlgorithmParameter> aps;
    aps.push_back(AlgorithmParameter("arg1_param","20","argument",true,Mantid::Kernel::Direction::Input));
Nick Draper's avatar
Nick Draper committed
    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);
Dickon Champion's avatar
Dickon Champion committed

  }


};

#endif /* ALGORITHMHISTORYTEST_H_*/