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
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef DELETETABLEROWSTEST_H_
#define DELETETABLEROWSTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidDataHandling/DeleteTableRows.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidAPI/TableRow.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/AnalysisDataService.h"
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace Mantid::DataHandling;
class DeleteTableRowsTest : public CxxTest::TestSuite
{
public:
void testDeleteIsDone()
{
//int iii;
//std::cin >> iii;
std::string wsName = "DeleteTableRowsTest_table";
ITableWorkspace_sptr tw = WorkspaceFactory::Instance().createTable("TableWorkspace");
AnalysisDataService::Instance().add(wsName,tw);
tw->addColumn("int","int");
for(size_t i = 0; i < 10; ++i)
{
TableRow row = tw->appendRow();
row << int(i);
}
IAlgorithm_sptr alg = AlgorithmManager::Instance().create("DeleteTableRows");
alg->setPropertyValue("TableWorkspace",wsName);
alg->setPropertyValue("Rows","1,3,5,7,9");
alg->execute();
TS_ASSERT_EQUALS(tw->rowCount(),5);
TS_ASSERT_EQUALS(tw->cell<int>(0,0),0);
TS_ASSERT_EQUALS(tw->cell<int>(1,0),2);
TS_ASSERT_EQUALS(tw->cell<int>(2,0),4);
TS_ASSERT_EQUALS(tw->cell<int>(3,0),6);
TS_ASSERT_EQUALS(tw->cell<int>(4,0),8);
AnalysisDataService::Instance().remove(wsName);
}
};
#endif /*DELETETABLEROWSTEST_H_*/