Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <iostream>
00022 #include <TaskContext.hpp>
00023 #include "unit.hpp"
00024
00025 using namespace std;
00026 using namespace boost;
00027 using namespace RTT;
00028 using namespace RTT::detail;
00029
00034 class RTT_UNIT_API OperationsFixture {
00035 public:
00036 OperationsFixture();
00037
00038 TaskContext* tc, *caller;
00039
00040
00041 double ret;
00042 double& m0r() { return ret; }
00043 const double& m0cr() { return ret; }
00044
00045
00046 bool comstr(const std::string& cs) { return !cs.empty(); }
00047
00048 double m1r(double& a) { a = 2*a; return a; }
00049 double m1cr(const double& a) { return a; }
00050
00051
00052 void vm0(void) { return; }
00053 double m0(void) { return -1.0; }
00054 double m1(int i) { if (i ==1) return -2.0; else return 2.0; }
00055 double m2(int i, double d) { if ( i == 1 && d == 2.0 ) return -3.0; else return 3.0; }
00056 double m3(int i, double d, bool c) { if ( i == 1 && d == 2.0 && c == true) return -4.0; else return 4.0; }
00057 double m4(int i, double d, bool c, std::string s) { if ( i == 1 && d == 2.0 && c == true && s == "hello") return -5.0; else return 5.0; }
00058 double m5(int i, double d, bool c, std::string s, float f) { if ( i == 1 && d == 2.0 && c == true && s == "hello" && f == 5.0f) return -6.0; else return 6.0; }
00059 double m6(int i, double d, bool c, std::string s, float f, char h) { if ( i == 1 && d == 2.0 && c == true && s == "hello" && f == 5.0f && h == 'a') return -7.0; else return 7.0; }
00060 double m7(int i, double d, bool c, std::string s, float f, char h, unsigned int st) { if ( i == 1 && d == 2.0 && c == true && s == "hello" && f == 5.0f && h == 'a' && st == 7) return -8.0; else return 8.0; }
00061
00062
00063 void m0except(void) { throw std::runtime_error("exception"); }
00064
00065 void print(const std::string& what) { cout << "print: " << what <<endl; }
00066 void printNumber(const std::string& what, int n) { cout << "print: " << what << n << endl; }
00067
00068 bool fail() {
00069 throw false;
00070 return true;
00071 }
00072
00073 bool good() {
00074 return true;
00075 }
00076
00077 bool assertBool(bool b) {
00078 if (!b) throw b;
00079 return b;
00080 }
00081
00082 bool isTrue(bool b) {
00083 return b;
00084 }
00085
00086 bool assertEqual(int a, int b)
00087 {
00088 if (a != b) {
00089 cerr << "AssertEqual failed: a != b " << a << " != " << b << "." << endl;
00090 throw b;
00091 }
00092 return a == b;
00093 }
00094 bool assertMsg( bool b, const std::string& msg) {
00095 if ( b == false ) {
00096 cout << "Asserted :" << msg << endl;
00097 throw b;
00098 }
00099 return true;
00100 }
00101 int increase() { return ++i;}
00102 void resetI() { i = 0; }
00103 int getI() const { return i; }
00104 int i;
00105
00106
00107 ~OperationsFixture();
00108
00109 void createOperationCallerFactories(TaskContext* target);
00110 void createOperationCallerFactories0(TaskContext* target);
00111 void createOperationCallerFactories1(TaskContext* target);
00112 void createOperationCallerFactories2(TaskContext* target);
00113 void createOperationCallerFactories3(TaskContext* target);
00114 void createOperationCallerFactories4(TaskContext* target);
00115 void createOperationCallerFactories5(TaskContext* target);
00116 void createOperationCallerFactories6(TaskContext* target);
00117 void createOperationCallerFactories7(TaskContext* target);
00118 };