Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #10408 Unit test AlgorithmHintStrategy
- Loading branch information
Harry Jeffery
committed
Oct 24, 2014
1 parent
1cdc745
commit 1a4efa5
Showing
3 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Code/Mantid/MantidQt/MantidWidgets/test/AlgorithmHintStrategyTest.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef MANTID_MANTIDWIDGETS_ALGORITHMHINTSTRATEGYTEST_H | ||
#define MANTID_MANTIDWIDGETS_ALGORITHMHINTSTRATEGYTEST_H | ||
|
||
#include <cxxtest/TestSuite.h> | ||
#include "MantidAPI/FrameworkManager.h" | ||
#include "MantidAPI/AlgorithmManager.h" | ||
#include "MantidQtMantidWidgets/HintStrategy.h" | ||
#include "MantidQtMantidWidgets/AlgorithmHintStrategy.h" | ||
|
||
using namespace MantidQt::MantidWidgets; | ||
using namespace Mantid::API; | ||
|
||
//===================================================================================== | ||
// Functional tests | ||
//===================================================================================== | ||
class AlgorithmHintStrategyTest : public CxxTest::TestSuite | ||
{ | ||
public: | ||
// This pair of boilerplate methods prevent the suite being created statically | ||
// This means the constructor isn't called when running other tests | ||
static AlgorithmHintStrategyTest *createSuite() { return new AlgorithmHintStrategyTest(); } | ||
static void destroySuite( AlgorithmHintStrategyTest *suite ) { delete suite; } | ||
|
||
AlgorithmHintStrategyTest() | ||
{ | ||
FrameworkManager::Instance(); | ||
m_propAlg = AlgorithmManager::Instance().create("PropertyAlgorithm"); | ||
//Expected hints for PropertyAlgorithm | ||
m_propMap["IntValue"] = ""; | ||
m_propMap["DoubleValue"] = ""; | ||
m_propMap["BoolValue"] = ""; | ||
m_propMap["StringValue"] = ""; | ||
m_propMap["PositiveIntValue"] = ""; | ||
m_propMap["PositiveIntValue1"] = ""; | ||
m_propMap["IntArray"] = ""; | ||
m_propMap["DoubleArray"] = ""; | ||
m_propMap["StringArray"] = ""; | ||
} | ||
|
||
void testCreateHints() | ||
{ | ||
boost::scoped_ptr<HintStrategy> strategy(new AlgorithmHintStrategy(m_propAlg, std::set<std::string>())); | ||
TS_ASSERT_EQUALS(m_propMap, strategy->createHints()); | ||
} | ||
|
||
void testBlacklist() | ||
{ | ||
std::set<std::string> blacklist; | ||
blacklist.insert("DoubleValue"); | ||
blacklist.insert("IntArray"); | ||
|
||
boost::scoped_ptr<HintStrategy> strategy(new AlgorithmHintStrategy(m_propAlg, blacklist)); | ||
auto expected = m_propMap; | ||
expected.erase("DoubleValue"); | ||
expected.erase("IntArray"); | ||
TS_ASSERT_EQUALS(expected, strategy->createHints()); | ||
} | ||
|
||
protected: | ||
IAlgorithm_sptr m_propAlg; | ||
std::map<std::string,std::string> m_propMap; | ||
}; | ||
|
||
#endif /*MANTID_MANTIDWIDGETS_ALGORITHMHINTSTRATEGYTEST_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
if ( PYUNITTEST_FOUND ) | ||
pyunittest_add_test (${CMAKE_CURRENT_SOURCE_DIR} MantidWidgetsTest ${TEST_PY_FILES} ) | ||
endif () | ||
|
||
if ( CXXTEST_FOUND ) | ||
include_directories ( SYSTEM ${CXXTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR} ) | ||
|
||
if ( GMOCK_FOUND AND GTEST_FOUND ) | ||
cxxtest_add_test ( MantidWidgetsTest ${TEST_FILES} ${GMOCK_TEST_FILES} ) | ||
target_link_libraries( MantidWidgetsTest MantidWidgets ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES} ) | ||
|
||
# Add to the 'UnitTests' group in VS | ||
set_property( TARGET MantidWidgetsTest PROPERTY FOLDER "UnitTests" ) | ||
endif () | ||
|
||
endif () |