forked from npshub/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnvironmentHistoryTest.h
48 lines (40 loc) · 1.55 KB
/
EnvironmentHistoryTest.h
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
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/EnvironmentHistory.h"
#include "MantidKernel/MantidVersion.h"
#include <cxxtest/TestSuite.h>
#include <sstream>
using namespace Mantid::Kernel;
class EnvironmentHistoryTest : public CxxTest::TestSuite {
public:
void testframeworkVersion() {
EnvironmentHistory EH;
TS_ASSERT_EQUALS(EH.frameworkVersion(), MantidVersion::version());
}
void testosName() {
EnvironmentHistory EH;
TS_ASSERT_EQUALS(EH.osName(), ConfigService::Instance().getOSName());
}
void testosVersion() {
EnvironmentHistory EH;
TS_ASSERT_EQUALS(EH.osVersion(), ConfigService::Instance().getOSVersion());
}
void testPopulate() {
std::string correctOutput = "Framework Version: " + std::string(MantidVersion::version()) + "\n";
correctOutput += "OS name: " + ConfigService::Instance().getOSName() + "\n";
correctOutput += "OS version: " + ConfigService::Instance().getOSVersion() + "\n";
// Not really much to test
EnvironmentHistory EH;
// dump output to sting
std::ostringstream output;
output.exceptions(std::ios::failbit | std::ios::badbit);
TS_ASSERT_THROWS_NOTHING(output << EH);
TS_ASSERT_EQUALS(output.str(), correctOutput);
}
};