summaryrefslogtreecommitdiff
path: root/cesar/maximus/functioncall/src/FunctionCallParameterTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/maximus/functioncall/src/FunctionCallParameterTest.cpp')
-rw-r--r--cesar/maximus/functioncall/src/FunctionCallParameterTest.cpp162
1 files changed, 162 insertions, 0 deletions
diff --git a/cesar/maximus/functioncall/src/FunctionCallParameterTest.cpp b/cesar/maximus/functioncall/src/FunctionCallParameterTest.cpp
new file mode 100644
index 0000000000..6d139b73e9
--- /dev/null
+++ b/cesar/maximus/functioncall/src/FunctionCallParameterTest.cpp
@@ -0,0 +1,162 @@
+
+#include "FunctionCallParameterTest.h"
+
+#include "FunctionCallParameter.h"
+
+#include "Error.h"
+#include "Logger.h"
+
+#include <iostream>
+using namespace std;
+
+CPPUNIT_TEST_SUITE_REGISTRATION (FunctionCallParameterTest);
+
+
+void FunctionCallParameterTest::setUp (void)
+{
+ logTest();
+
+ mpFunctionCallParameter = new FunctionCallParameter();
+}
+
+
+void FunctionCallParameterTest::tearDown (void)
+{
+ logTest();
+
+ if (NULL != mpFunctionCallParameter)
+ {
+ delete (mpFunctionCallParameter);
+ mpFunctionCallParameter = NULL;
+ }
+}
+
+
+void FunctionCallParameterTest::setNameTest (void)
+{
+ logTest();
+
+ if (NULL != mpFunctionCallParameter)
+ {
+ try
+ {
+ string name1("name1");
+ mpFunctionCallParameter->setName(name1);
+
+ mpFunctionCallParameter->displayParameter();
+ CPPUNIT_ASSERT_MESSAGE ( "setName failed",
+ 0 == name1.compare(mpFunctionCallParameter->getName()) );
+
+ char name2 [] = "name2";
+ mpFunctionCallParameter->setName(name2);
+
+ mpFunctionCallParameter->displayParameter();
+ CPPUNIT_ASSERT_MESSAGE ( "setName failed",
+ (mpFunctionCallParameter->getName().length() == strlen(name2))
+ && (0 == memcmp(name2, mpFunctionCallParameter->getName().c_str(), strlen(name2)+1)) );
+ }
+ catch (Error &e)
+ {
+ e.display();
+ CPPUNIT_FAIL ( "Catch exception" );
+ }
+ }
+ else
+ {
+ CPPUNIT_FAIL ( "Function call parameter pointer is NULL" );
+ }
+}
+
+
+void FunctionCallParameterTest::setValueTest (void)
+{
+ logTest();
+
+ if (NULL != mpFunctionCallParameter)
+ {
+ try
+ {
+ const unsigned long length = 10;
+ unsigned char value [length+1] = "1234567890";
+ mpFunctionCallParameter->setValueLength(length);
+ mpFunctionCallParameter->setValue(value);
+
+ mpFunctionCallParameter->displayParameter();
+ CPPUNIT_ASSERT_MESSAGE ( "setValue failed",
+ 0 == memcmp(value, mpFunctionCallParameter->getValue(), length) );
+ }
+ catch (Error &e)
+ {
+ e.display();
+ CPPUNIT_FAIL ( "Catch exception" );
+ }
+ }
+ else
+ {
+ CPPUNIT_FAIL ( "Function call parameter pointer is NULL" );
+ }
+}
+
+
+void FunctionCallParameterTest::setValueLengthTest (void)
+{
+ logTest();
+
+ if (NULL != mpFunctionCallParameter)
+ {
+ try
+ {
+ const unsigned long length = 10;
+ mpFunctionCallParameter->setValueLength(length);
+
+ mpFunctionCallParameter->displayParameter();
+ CPPUNIT_ASSERT_MESSAGE ( "setValueLength failed",
+ length == mpFunctionCallParameter->getValueLength() );
+ }
+ catch (Error &e)
+ {
+ e.display();
+ CPPUNIT_FAIL ( "Catch exception" );
+ }
+ }
+ else
+ {
+ CPPUNIT_FAIL ( "Function call parameter pointer is NULL" );
+ }
+}
+
+
+void FunctionCallParameterTest::constructorsTest (void)
+{
+ logTest();
+
+ if (NULL != mpFunctionCallParameter)
+ {
+ try
+ {
+ FunctionCallParameter parameter1 ("parameter1", 3, (unsigned char *)"abc");
+ FunctionCallParameter parameter2(parameter1);
+ FunctionCallParameter parameter3 = parameter2;
+
+ parameter1.displayParameter();
+ parameter2.displayParameter();
+ parameter3.displayParameter();
+ CPPUNIT_ASSERT_MESSAGE ( "constructors failed",
+ (0 == parameter1.getName().compare("parameter1"))
+ && (3 == parameter1.getValueLength())
+ && (0 == memcmp(parameter1.getValue(), "abc", 3))
+ && (parameter1 == parameter2)
+ && (parameter2 == parameter3) );
+ }
+ catch (Error &e)
+ {
+ e.display();
+ CPPUNIT_FAIL ( "Catch exception" );
+ }
+ }
+ else
+ {
+ CPPUNIT_FAIL ( "Function call parameter pointer is NULL" );
+ }
+}
+