Newer
Older
Janik Zikovsky
committed
#ifndef MANTID_KERNEL_PROGRESSTEXTTEST_H_
#define MANTID_KERNEL_PROGRESSTEXTTEST_H_
Janik Zikovsky
committed
#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
#include "MantidKernel/System.h"
#include <iostream>
#include <iomanip>
#include <cstdlib>
Janik Zikovsky
committed
#include "MantidKernel/ProgressText.h"
Janik Zikovsky
committed
Janik Zikovsky
committed
using namespace Mantid::Kernel;
Janik Zikovsky
committed
class ProgressTextTest : public CxxTest::TestSuite
{
public:
void test_setNumSteps()
{
ProgressText p(0.5, 1.0, 10);
TS_ASSERT_THROWS_NOTHING(p.setNumSteps(100));
}
void test_constructors()
{
// No steps?
TS_ASSERT_THROWS_NOTHING(ProgressText p(0.0, 1.0, 0); );
// Max is < min
TS_ASSERT_THROWS_NOTHING(ProgressText p(NULL, 1.0, 0.5, 10); );
}
Janik Zikovsky
committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/// Disabled because it has text output
void xtest_with_stdout()
{
ProgressText p(0.5, 1.0, 10);
// 4 outputs
p.report();
p.report("I have an optional message");
p.report();
p.report();
p.setNumSteps(100);
// These should output only 2 lines. The % will go backwards though
p.report();
p.report();
p.report();
p.report();
p.setNumSteps(5);
p.report();
}
// /// Disabled because it has text output
// void test_on_one_line()
// {
// ProgressText p(0.0, 1.0, 100, false);
// for (int i=0; i<100; i++)
// {
// std::string msg = "";
// for (int i = 0; i < std::rand() %10; i++)
// msg += "bla";
// p.report(msg);
// usleep(10000);
// }
// }
};
Janik Zikovsky
committed
#endif