26 #include <itksys/SystemTools.hxx>
28 static const std::string
filename = itksys::SystemTools::GetCurrentWorkingDirectory() +
"/TinyXMLTest.txt";
34 return pow(10.0, -1.0 * ((
double)requiredDecimalPlaces));
42 static bool Setup(
double valueToWrite)
45 TiXmlDocument document;
46 auto decl =
new TiXmlDeclaration(
"1.0",
"",
"");
47 document.LinkEndChild(decl);
49 auto version =
new TiXmlElement(
"Version");
50 version->SetAttribute(
"Writer", __FILE__);
51 version->SetAttribute(
"CVSRevision",
"$Revision: 17055 $");
52 version->SetAttribute(
"FileVersion", 1);
53 document.LinkEndChild(version);
58 document.LinkEndChild(vElement);
66 TiXmlDocument document;
71 return TIXML_NO_ATTRIBUTE;
93 "Test if setup and teardown correctly writes data to " <<
filename <<
" and deletes the file after the test");
107 "checking if readout mechanism works.");
112 const double valueToWrite = -1.123456;
113 const int validDigitsAfterComma = 6;
114 const double neededPrecision =
calcPrecision(validDigitsAfterComma + 1);
122 mitk::Equal(valueToWrite, readValue, neededPrecision),
123 std::setprecision(validDigitsAfterComma) <<
"Testing if value " << valueToWrite <<
" equals " << readValue
124 <<
" which was retrieved from TinyXML document");
131 const double valueToWrite = -1.12345678910111;
132 const int validDigitsAfterComma = 14;
133 const double neededPrecision =
calcPrecision(validDigitsAfterComma + 1);
141 mitk::Equal(valueToWrite, readValue, neededPrecision),
142 std::setprecision(validDigitsAfterComma) <<
"Testing if value " << valueToWrite <<
" equals " << readValue
143 <<
" which was retrieved from TinyXML document");
static void Test_Setup_works()
static void Test_DoubleValueWriteOut()
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
static const std::string elementToStoreAttributeName
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
static const std::string filename
static double calcPrecision(const unsigned int requiredDecimalPlaces)
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
static void Test_ReadOutValue_works()
static int readValueFromSetupDocument(double &readOutValue)
static const std::string attributeToStoreName
static void Test_DoubleValueWriteOut_manyDecimalPlaces()
static bool Setup(double valueToWrite)
int mitkTinyXMLTest(int, char *[])