00001 #include "ippResponseTestCase.h"
00002
00003 #include "ippdme/Misc/ippStringBuilder.h"
00004 #include "ippdme/Response/ippAckResponse.h"
00005 #include "ippdme/Response/ippCenterPartResponse.h"
00006 #include "ippdme/Response/ippAlignResponse.h"
00007 #include "ippdme/Response/ippChangeToolEResponse.h"
00008 #include "ippdme/Response/ippEnumPropResponse.h"
00009 #include "ippdme/Response/ippErrorResponse.h"
00010 #include "ippdme/Response/ippGetChangeToolActionResponse.h"
00011 #include "ippdme/Response/ippGetCoordSystemResponse.h"
00012 #include "ippdme/Response/ippGetCsyTransformationResponse.h"
00013 #include "ippdme/Response/ippGetDMEVersionResponse.h"
00014 #include "ippdme/Response/ippGetErrStatusEResponse.h"
00015 #include "ippdme/Response/ippGetMachineClassResponse.h"
00016 #include "ippdme/Response/ippGetPropResponse.h"
00017 #include "ippdme/Response/ippGoToEResponse.h"
00018 #include "ippdme/Response/ippIsHomedResponse.h"
00019 #include "ippdme/Response/ippIsUserEnabledResponse.h"
00020 #include "ippdme/Response/ippKeyPressEResponse.h"
00021 #include "ippdme/Response/ippOnMoveReportEResponse.h"
00022 #include "ippdme/Response/ippPtMeasEResponse.h"
00023 #include "ippdme/Response/ippPtMeasOrGetResponse.h"
00024 #include "ippdme/Response/ippScanResponse.h"
00025 #include "ippdme/Response/ippSetPropEResponse.h"
00026 #include "ippdme/Response/ippStringResponse.h"
00027 #include "ippdme/Response/ippTiltCenterPartResponse.h"
00028 #include "ippdme/Response/ippTiltPartResponse.h"
00029
00030 #include "ippdme/Property/ippOnePropertyNumber.h"
00031
00032 #include "ippdme/Parser/ippResponseParser.h"
00033
00034 #include "ippMemoryLeakDetector.h"
00035
00041 void recheck_with_parser(ippResponse& r,bool bParsingShouldFail = false)
00042 {
00043 ippMemoryLeakDetector _leakDetector;
00044 ippResponseParser parser;
00045 std::string t = r.getResponseString();
00046 parser.setInput(t.c_str());
00047
00048 ippResponsePtr r_check= parser.parseResponse();
00049 if (bParsingShouldFail) {
00050 IPP_UTEST_ASSERT(!r_check);
00051 if(r_check) {
00052 std::cout << " parsing should have failed : " << std::endl << t << std::endl;
00053 std::cout << parser.getErrorMessageString() <<std::endl;
00054 }
00055 return ;
00056 }
00057 if (r_check) {
00058 std::string t_check = r_check->getResponseString();
00059 IPP_UTEST_ASSERT_EQUALS(t,t_check);
00060 } else {
00061
00062 IPP_UTEST_ASSERT_M(std::string(" failing parsing \n")+t ,r_check);
00063 std::cout << " failing parsing " << std::endl << t << std::endl;
00064 std::cout << parser.getErrorMessageString() <<std::endl;
00065 }
00066
00067 }
00068
00069 void ippResponseTestCase::testAckResponse()
00070 {
00071 ippMemoryLeakDetector _leakDetector;
00072 {
00073 ippAckResponse r(100, CommandTag);
00074 std::string t = r.getResponseString();
00075 IPP_UTEST_ASSERT_EQUALS(t,"00100 &"IPP_END_STRING);
00076 recheck_with_parser(r);
00077 }
00078 {
00079 ippAckResponse r(100, EventTag);
00080 std::string t = r.getResponseString();
00081 IPP_UTEST_ASSERT_EQUALS(t,"E0100 &"IPP_END_STRING);
00082 recheck_with_parser(r);
00083
00084 }
00085
00086 }
00087
00088 void ippResponseTestCase::testAlignResponse()
00089 {
00090 ippMemoryLeakDetector _leakDetector;
00091 {
00092 ippAlignResponse r(65,10.,20.,40.,11.,21.,41.);
00093 std::string t = r.getResponseString();
00094 IPP_UTEST_ASSERT_EQUALS(t,"00065 # (10., 20., 40., 11., 21., 41.)"IPP_END_STRING);
00095 recheck_with_parser(r);
00096 }
00097 {
00098 ippAlignResponse r(65,10.,20.,40.);
00099 std::string t = r.getResponseString();
00100 IPP_UTEST_ASSERT_EQUALS(t,"00065 # (10., 20., 40.)"IPP_END_STRING);
00101 recheck_with_parser(r);
00102
00103 }
00104
00105 }
00106 void ippResponseTestCase::testCenterPartResponse()
00107 {
00108 ippMemoryLeakDetector _leakDetector;
00109 {
00110 ippCenterPartResponse r(65,true);
00111 std::string t = r.getResponseString();
00112 IPP_UTEST_ASSERT_EQUALS(t,"00065 # CenterPart(1)"IPP_END_STRING);
00113 recheck_with_parser(r);
00114 }
00115 {
00116 ippCenterPartResponse r(65,false);
00117 std::string t = r.getResponseString();
00118 IPP_UTEST_ASSERT_EQUALS(t,"00065 # CenterPart(0)"IPP_END_STRING);
00119 recheck_with_parser(r);
00120 }
00121
00122 }
00123 #define QUOTE(a) "\""a"\""
00124
00125 void ippResponseTestCase::testChangeToolEResponse()
00126 {
00127 ippMemoryLeakDetector _leakDetector;
00128 {
00129 ippChangeToolEResponse r("MyTool");
00130 std::string t = r.getResponseString();
00131
00132 const std::string expected_String="E0000 # ChangeTool(\"MyTool\")"IPP_END_STRING;
00133
00134 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00135 recheck_with_parser(r);
00136 }
00137 {
00138 ippChangeToolEResponse r;
00139 std::string t = r.getResponseString();
00140 const std::string expected_String="E0000 # ChangeTool(\"\")"IPP_END_STRING;
00141 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00142 recheck_with_parser(r);
00143 }
00144
00145 }
00146
00147
00148 void ippResponseTestCase::testEnumPropResponse()
00149 {
00150 ippMemoryLeakDetector _leakDetector;
00151 {
00152 ippEnumPropResponse r(1234,"SomeProp","SomeValue");
00153 std::string t = r.getResponseString();
00154 const std::string expected_String="01234 # \"SomeProp\", \"SomeValue\""IPP_END_STRING;
00155 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00156 recheck_with_parser(r);
00157 }
00158 }
00159 void ippResponseTestCase::testErrorResponse()
00160 {
00161
00162
00163
00164
00165
00166 ippMemoryLeakDetector _leakDetector;
00167 {
00168 ippErrorResponse r(25,CommandTag,ProtocolError,"reason");
00169 std::string t = r.getResponseString();
00170 const std::string expected_String="00025 ! Error(3, 0008, \"reason\", \"Protocol error\")"IPP_END_STRING;
00171 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00172 recheck_with_parser(r);
00173 }
00174
00175 {
00176 ippErrorResponse r(25,CommandTag,ProtocolError,"\t\"\"");
00177 std::string t = r.getResponseString();
00178 const std::string expected_String="00025 ! Error(3, 0008, \"?##\", \"Protocol error\")"IPP_END_STRING;
00179 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00180 recheck_with_parser(r);
00181 }
00182
00183 {
00184 ippErrorResponse r(54,CommandTag,UseClearAllErrorsToCont,"Get");
00185 std::string t = r.getResponseString();
00186 const std::string expected_String="00054 ! Error(2, 0514, \"Get\", \"Use ClearAllErrors to continue\")"IPP_END_STRING;
00187 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00188 recheck_with_parser(r);
00189 }
00190 }
00191
00192 void ippResponseTestCase::testGetChangeToolActionResponse()
00193 {
00194 ippMemoryLeakDetector _leakDetector;
00195
00196 ippGetChangeToolActionResponse r(25,MoveAuto,10.,20.,30.);
00197 std::string t = r.getResponseString();
00198 IPP_UTEST_ASSERT_EQUALS(t,"00025 # ChangeToolAction(MoveAuto, X(10.), Y(20.), Z(30.))"IPP_END_STRING);
00199 recheck_with_parser(r);
00200 }
00201
00202 void ippResponseTestCase::testGetCoordSystemResponse()
00203 {
00204 ippMemoryLeakDetector _leakDetector;
00205
00206 {
00207 ippGetCoordSystemResponse r(25,MachineCsy);
00208 std::string t = r.getResponseString();
00209 IPP_UTEST_ASSERT_EQUALS(t,"00025 # CoordSystem(MachineCsy)"IPP_END_STRING);
00210 recheck_with_parser(r);
00211 }
00212 {
00213 ippGetCoordSystemResponse r(25,MoveableMachineCsy);
00214 std::string t = r.getResponseString();
00215 IPP_UTEST_ASSERT_EQUALS(t,"00025 # CoordSystem(MoveableMachineCsy)"IPP_END_STRING);
00216 recheck_with_parser(r);
00217 }
00218 {
00219 ippGetCoordSystemResponse r(25,MultipleArmCsy);
00220 std::string t = r.getResponseString();
00221 IPP_UTEST_ASSERT_EQUALS(t,"00025 # CoordSystem(MultipleArmCsy)"IPP_END_STRING);
00222 recheck_with_parser(r);
00223 }
00224 {
00225 ippGetCoordSystemResponse r(25,PartCsy);
00226 std::string t = r.getResponseString();
00227 IPP_UTEST_ASSERT_EQUALS(t,"00025 # CoordSystem(PartCsy)"IPP_END_STRING);
00228 recheck_with_parser(r);
00229 }
00230
00231 {
00232 ippGetCoordSystemResponse r(25,JogDisplayCsy);
00233 std::string t = r.getResponseString();
00234 IPP_UTEST_ASSERT_EQUALS(t,"00025 # CoordSystem(JogDisplayCsy)"IPP_END_STRING);
00235 recheck_with_parser(r, true);
00236 }
00237 {
00238 ippGetCoordSystemResponse r(25,JogMoveCsy);
00239 std::string t = r.getResponseString();
00240 IPP_UTEST_ASSERT_EQUALS(t,"00025 # CoordSystem(JogMoveCsy)"IPP_END_STRING);
00241 recheck_with_parser(r,true);
00242 }
00243 {
00244 ippGetCoordSystemResponse r(25,SensorCsy);
00245 std::string t = r.getResponseString();
00246 IPP_UTEST_ASSERT_EQUALS(t,"00025 # CoordSystem(SensorCsy)"IPP_END_STRING);
00247 recheck_with_parser(r,true);
00248 }
00249
00250
00251 }
00252
00253 void ippResponseTestCase::testGetCsyTransformationResponse()
00254 {
00255 ippMemoryLeakDetector _leakDetector;
00256
00257 ippGetCsyTransformationResponse r(25, 10.,20.,30., 45.,60.,90.);
00258 std::string t = r.getResponseString();
00259 IPP_UTEST_ASSERT_EQUALS(t,"00025 # GetCsyTransformation(10., 20., 30., 45., 60., 90.)"IPP_END_STRING);
00260 recheck_with_parser(r);
00261
00262 }
00263 void ippResponseTestCase::testGetDMEVersionResponse()
00264 {
00265 ippMemoryLeakDetector _leakDetector;
00266
00267 ippGetDMEVersionResponse r(25,"1.4.0");
00268 std::string t = r.getResponseString();
00269 const std::string expected_String="00025 # DMEVersion(\"1.4.0\")"IPP_END_STRING;
00270 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00271 recheck_with_parser(r);
00272
00273
00274 }
00275
00276 void ippResponseTestCase::testGetErrStatusEResponse()
00277 {
00278 ippMemoryLeakDetector _leakDetector;
00279 {
00280 ippGetErrStatusEResponse r(25,true);
00281 std::string t = r.getResponseString();
00282 IPP_UTEST_ASSERT_EQUALS(t,"E0025 # ErrStatus(1)"IPP_END_STRING);
00283 recheck_with_parser(r);
00284 }
00285 {
00286 ippGetErrStatusEResponse r(25,false);
00287 std::string t = r.getResponseString();
00288 IPP_UTEST_ASSERT_EQUALS(t,"E0025 # ErrStatus(0)"IPP_END_STRING);
00289 recheck_with_parser(r);
00290 }
00291 }
00292 void ippResponseTestCase::testGetMachineClassResponse()
00293 {
00294 ippMemoryLeakDetector _leakDetector;
00295 {
00296 ippGetMachineClassResponse r(25,CartCMMWithRotaryTable);
00297 std::string t = r.getResponseString();
00298 const std::string expected_String="00025 # GetMachineClass(CartCMMWithRotaryTable)"IPP_END_STRING;
00299 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00300 recheck_with_parser(r);
00301 }
00302 {
00303 ippGetMachineClassResponse r(25,CartCMM);
00304 std::string t = r.getResponseString();
00305 const std::string expected_String="00025 # GetMachineClass(CartCMM)"IPP_END_STRING;
00306 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00307 recheck_with_parser(r);
00308 }
00309
00310 }
00311
00312 void ippResponseTestCase::testGetPropResponse()
00313 {
00314 ippMemoryLeakDetector _leakDetector;
00315 {
00316 const int N_PROP = 1;
00317 ippGetPropResponse r(25,CommandTag);
00318 r.append(new ippOnePropertyNumber(ippProp(Tool,GoToPar,Accel), 12.5));
00319
00320 std::string t = r.getResponseString();
00321 IPP_UTEST_ASSERT_EQUALS(t,"00025 # Tool.GoToPar.Accel(12.5)"IPP_END_STRING);
00322 recheck_with_parser(r);
00323 }
00324 {
00325 ippGetPropResponse r(25,CommandTag);
00326 r.append(new ippOnePropertyNumber(ippProp(Tool,GoToPar,Speed), 1.5));
00327 r.append(new ippOnePropertyNumber(ippProp(Tool,GoToPar,Speed), 120.5));
00328 r.append(new ippOnePropertyNumber(ippProp(FoundTool,GoToPar,Speed,Min),12.5));
00329
00330 std::string t = r.getResponseString();
00331 IPP_UTEST_ASSERT_EQUALS(t,"00025 # Tool.GoToPar.Speed(1.5), Tool.GoToPar.Speed(120.5), FoundTool.GoToPar.Speed.Min(12.5)"IPP_END_STRING);
00332 recheck_with_parser(r);
00333 }
00334 {
00335 ippGetPropResponse r(25,CommandTag);
00336 r.append(new ippOnePropertyNumber(ippProp(Part,Temperature),12.5));
00337 std::string t = r.getResponseString();
00338 IPP_UTEST_ASSERT_EQUALS(t,"00025 # Part.Temperature(12.5)"IPP_END_STRING);
00339 recheck_with_parser(r);
00340 }
00341 }
00342 void ippResponseTestCase::testGoToEResponse()
00343 {
00344 ippMemoryLeakDetector _leakDetector;
00345
00346
00347
00348
00349
00350
00351
00352 {
00353 ippGoToEResponse r(
00354 true,false,false,
00355 false,false,false,
00356 false,false,false,
00357 10.0,1.0,15.0,45.0,0.0,11.,12.,13.0);
00358 std::string t = r.getResponseString();
00359 IPP_UTEST_ASSERT_EQUALS(t,"E0000 # GoTo(ER(10.))"IPP_END_STRING);
00360 recheck_with_parser(r);
00361 }
00362 {
00363 ippGoToEResponse r(
00364 true,false,false,
00365 true,false,false,
00366 false,false,false,
00367 10.0,1.0,15.0,45.0,0.0,11.,12.,13.0);
00368 std::string t = r.getResponseString();
00369 IPP_UTEST_ASSERT_EQUALS(t,"E0000 # GoTo(ER(10.), Tool.A(15.))"IPP_END_STRING);
00370 recheck_with_parser(r);
00371 }
00372 {
00373 ippGoToEResponse r(
00374 true,false,false,
00375 true,true,false,
00376 false,false,false,
00377 10.0,1.0,15.0,45.0,0.0,11.,12.,13.0);
00378 std::string t = r.getResponseString();
00379 IPP_UTEST_ASSERT_EQUALS(t,"E0000 # GoTo(ER(10.), Tool.A(15.), Tool.B(45.))"IPP_END_STRING);
00380 recheck_with_parser(r);
00381 }
00382 {
00383 ippGoToEResponse r(
00384 false,false,false,
00385 false,false,false,
00386 true,true,true,
00387 10.0,1.0,15.0,45.0,0.0,11.,12.,13.0);
00388 std::string t = r.getResponseString();
00389 IPP_UTEST_ASSERT_EQUALS(t,"E0000 # GoTo(X(11.), Y(12.), Z(13.))"IPP_END_STRING);
00390 recheck_with_parser(r);
00391 }
00392 }
00393
00394 void ippResponseTestCase::testIsHomedResponse()
00395 {
00396 ippMemoryLeakDetector _leakDetector;
00397
00398 {
00399 ippIsHomedResponse r(25,true);
00400 std::string t = r.getResponseString();
00401 IPP_UTEST_ASSERT_EQUALS(t,"00025 # IsHomed(1)"IPP_END_STRING);
00402 recheck_with_parser(r);
00403 }
00404 {
00405 ippIsHomedResponse r(25,false);
00406 std::string t = r.getResponseString();
00407 IPP_UTEST_ASSERT_EQUALS(t,"00025 # IsHomed(0)"IPP_END_STRING);
00408 recheck_with_parser(r);
00409 }
00410 }
00411 void ippResponseTestCase::testIsUserEnabledResponse()
00412 {
00413 ippMemoryLeakDetector _leakDetector;
00414
00415 {
00416 ippIsUserEnabledResponse r(25,true);
00417 std::string t = r.getResponseString();
00418 IPP_UTEST_ASSERT_EQUALS(t,"00025 # IsUserEnabled(1)"IPP_END_STRING);
00419 recheck_with_parser(r);
00420 }
00421 {
00422 ippIsUserEnabledResponse r(25,false);
00423 std::string t = r.getResponseString();
00424 IPP_UTEST_ASSERT_EQUALS(t,"00025 # IsUserEnabled(0)"IPP_END_STRING);
00425 recheck_with_parser(r);
00426 }
00427 }
00428
00429 void ippResponseTestCase::testKeyPressEResponse()
00430 {
00431 ippMemoryLeakDetector _leakDetector;
00432
00433 {
00434 ippKeyPressEResponse r("A");
00435 std::string t = r.getResponseString();
00436 const std::string expected_String="E0000 # KeyPress(\"A\")"IPP_END_STRING;
00437 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00438 recheck_with_parser(r);
00439 }
00440 {
00441 ippKeyPressEResponse r("F2");
00442 std::string t = r.getResponseString();
00443 const std::string expected_String="E0000 # KeyPress(\"F2\")"IPP_END_STRING;
00444 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00445 recheck_with_parser(r);
00446 }
00447 }
00448 void ippResponseTestCase::testOnMoveReportEResponse()
00449 {
00450 ippMemoryLeakDetector _leakDetector;
00451
00452 {
00453 ippOnMoveReportEResponse r(25);
00454 r.setHasX(true);r.setX(10.0);
00455 r.setHasZ(true);r.setZ(13.0);
00456
00457 std::string t = r.getResponseString();
00458 IPP_UTEST_ASSERT_EQUALS(t,"E0025 # X(10.), Z(13.)"IPP_END_STRING);
00459 recheck_with_parser(r);
00460 }
00461 {
00462 ippOnMoveReportEResponse r(25);
00463 r.setHasX(true);r.setX(10.0);
00464 r.setHasZ(true);r.setZ(13.0);
00465 r.setHasToolA(true);r.setToolA(35.0);
00466 r.setHasToolB(true);r.setToolB(45.0);
00467
00468 std::string t = r.getResponseString();
00469 IPP_UTEST_ASSERT_EQUALS(t,"E0025 # X(10.), Z(13.), Tool.A(35.), Tool.B(45.)"IPP_END_STRING);
00470 recheck_with_parser(r);
00471 }
00472 }
00473
00474
00475
00476 void ippResponseTestCase::testPtMeasEResponse()
00477 {
00478 ippMemoryLeakDetector _leakDetector;
00479
00480 ippPtMeasEResponse r;
00481 r.setHasX(true);r.setX(10.0);
00482 r.setHasZ(true);r.setZ(13.0);
00483 r.setHasIJK(true);r.setIJK(1.,0.,0.0);
00484
00485 std::string t = r.getResponseString();
00486 IPP_UTEST_ASSERT_EQUALS(t,"E0000 # PtMeas(IJK(1., 0., 0.), X(10.), Z(13.))"IPP_END_STRING);
00487 recheck_with_parser(r);
00488
00489 }
00490
00491 void ippResponseTestCase::testPtMeasOrGetResponse()
00492 {
00493 ippMemoryLeakDetector _leakDetector;
00494
00495 {
00496 ippPtMeasOrGetResponse r(25);
00497 r.setHasX(true);r.setX(10.0);
00498 r.setHasZ(true);r.setZ(13.0);
00499 r.setHasIJK(true);r.setIJK(1.,0.,0.0);
00500 r.setHasER(true);r.setER(1.0);
00501 std::string t = r.getResponseString();
00502 IPP_UTEST_ASSERT_EQUALS(t,"00025 # IJK(1., 0., 0.), ER(1.), X(10.), Z(13.)"IPP_END_STRING);
00503 recheck_with_parser(r);
00504 }
00505 {
00506 ippPtMeasOrGetResponse r(25);
00507 r.setHasQ(true);r.setQ(100.0);
00508 r.setHasIJK(true);r.setIJK(1.,0.,0.0);
00509 r.setHasER(true);r.setER(1.0);
00510 r.setHasIJKAct(true);r.setIJKAct(1);
00511 std::string t = r.getResponseString();
00512 IPP_UTEST_ASSERT_EQUALS(t,"00025 # IJK(1., 0., 0.), IJKAct(1), ER(1.), Q(100.)"IPP_END_STRING);
00513 recheck_with_parser(r);
00514 }
00515
00516 }
00517
00518 void ippResponseTestCase::testScanResponse()
00519 {
00520 ippMemoryLeakDetector _leakDetector;
00521
00522 ippScanResponse r(25);
00523 double d[] ={ 1.,2.,3.,4.,5.,6.,7.};
00524 r.setData(sizeof(d)/sizeof(d[0]),d);
00525
00526 std::string t = r.getResponseString();
00527
00528 IPP_UTEST_ASSERT_EQUALS(t,"00025 # 1., 2., 3., 4., 5., 6., 7."IPP_END_STRING);
00529 recheck_with_parser(r);
00530 }
00531
00532 void ippResponseTestCase::testSetPropEResponse()
00533 {
00534 ippMemoryLeakDetector _leakDetector;
00535
00536 ippSetPropEResponse r;
00537 r.addPropValue(ippProp(FoundTool,PtMeasPar,Speed,Actual),1.0);
00538
00539 std::string t = r.getResponseString();
00540 IPP_UTEST_ASSERT_EQUALS(t,"E0000 # SetProp(FoundTool.PtMeasPar.Speed.Act(1.))"IPP_END_STRING);
00541 recheck_with_parser(r);
00542
00543 }
00544 void ippResponseTestCase::testSetPropEResponseMulti()
00545 {
00546 ippMemoryLeakDetector _leakDetector;
00547
00548 ippSetPropEResponse r;
00549 r.addPropValue(ippProp(FoundTool,PtMeasPar,Speed,Actual),1.0);
00550
00551 r.addPropValue(ippProp(FoundTool,GoToPar,Speed),10.0);
00552
00553 std::string t = r.getResponseString();
00554 IPP_UTEST_ASSERT_EQUALS(t,"E0000 # SetProp(FoundTool.PtMeasPar.Speed.Act(1.), FoundTool.GoToPar.Speed(10.))"IPP_END_STRING);
00555 recheck_with_parser(r);
00556
00557 }
00558
00559 void ippResponseTestCase::testStringResponse()
00560 {
00561 ippMemoryLeakDetector _leakDetector;
00562
00563 ippStringResponse r(25,"SomeString");
00564 std::string t = r.getResponseString();
00565 const std::string expected_String="00025 # \"SomeString\""IPP_END_STRING;
00566 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00567 recheck_with_parser(r);
00568 }
00569
00570 void ippResponseTestCase::testTiltCenterPartResponse()
00571 {
00572 ippMemoryLeakDetector _leakDetector;
00573
00574 {
00575 ippTiltCenterPartResponse r(25,true);
00576 std::string t = r.getResponseString();
00577 IPP_UTEST_ASSERT_EQUALS(t,"00025 # TiltCenterPart(1)"IPP_END_STRING);
00578 recheck_with_parser(r);
00579 }
00580 {
00581 ippTiltCenterPartResponse r(25,false);
00582 std::string t = r.getResponseString();
00583 IPP_UTEST_ASSERT_EQUALS(t,"00025 # TiltCenterPart(0)"IPP_END_STRING);
00584 recheck_with_parser(r);
00585 }
00586 }
00587
00588
00589 void ippResponseTestCase::testTiltPartResponse()
00590 {
00591 ippMemoryLeakDetector _leakDetector;
00592
00593 {
00594 ippTiltPartResponse r(25,true);
00595 std::string t = r.getResponseString();
00596 IPP_UTEST_ASSERT_EQUALS(t,"00025 # TiltPart(1)"IPP_END_STRING);
00597 recheck_with_parser(r);
00598 }
00599 {
00600 ippTiltPartResponse r(25,false);
00601 std::string t = r.getResponseString();
00602 IPP_UTEST_ASSERT_EQUALS(t,"00025 # TiltPart(0)"IPP_END_STRING);
00603 recheck_with_parser(r);
00604 }
00605
00606 }
00607
00608 void ippResponseTestCase::testToolAlignmentResponse()
00609 {
00610 ippMemoryLeakDetector _leakDetector;
00611 {
00612
00613
00614 ippGetPropResponse r(25,CommandTag);
00615 r.append(new ippOnePropertyAlignment(Tool,1.,2.0,3.0));
00616 std::string t = r.getResponseString();
00617 IPP_UTEST_ASSERT_EQUALS(t,"00025 # Tool.Alignment(1., 2., 3.)"IPP_END_STRING);
00618 recheck_with_parser(r);
00619 }
00620 {
00621
00622
00623 ippGetPropResponse r(25,CommandTag);
00624 r.append(new ippOnePropertyAlignment(Tool,1.,2.0,3.0,4.0,5.0,6.0));
00625 std::string t = r.getResponseString();
00626 IPP_UTEST_ASSERT_EQUALS(t,"00025 # Tool.Alignment(1., 2., 3., 4., 5., 6.)"IPP_END_STRING);
00627 recheck_with_parser(r);
00628 }
00629 {
00630
00631
00632
00633
00634 ippGetPropResponse r(25,CommandTag);
00635 r.append(new ippOnePropertyAlignment(FoundTool,1.,2.0,3.0));
00636 std::string t = r.getResponseString();
00637 IPP_UTEST_ASSERT_EQUALS(t,"00025 # FoundTool.Alignment(1., 2., 3.)"IPP_END_STRING);
00638 recheck_with_parser(r);
00639 }
00640 {
00641
00642
00643
00644
00645 ippGetPropResponse r(25,CommandTag);
00646 r.append(new ippOnePropertyAlignment(FoundTool,1.,2.0,3.0,4.0,5.0,6.0));
00647 std::string t = r.getResponseString();
00648 IPP_UTEST_ASSERT_EQUALS(t,"00025 # FoundTool.Alignment(1., 2., 3., 4., 5., 6.)"IPP_END_STRING);
00649 recheck_with_parser(r);
00650 }
00651 }
00652
00653 void ippResponseTestCase::testToolAlignmentVolumeResponse()
00654 {
00655 ippMemoryLeakDetector _leakDetector;
00656 {
00657
00658
00659 ippGetPropResponse r(25,CommandTag);
00660 r.append(new ippOnePropertyAlignmentVolume(Tool,1.,2.0,3.0,4.0));
00661 std::string t = r.getResponseString();
00662 IPP_UTEST_ASSERT_EQUALS(t,"00025 # Tool.AlignmentVolume(SPH, 1., 2., 3., 4.)"IPP_END_STRING);
00663 recheck_with_parser(r);
00664 }
00665 {
00666
00667
00668
00669
00670 ippGetPropResponse r(25,CommandTag);
00671 r.append(new ippOnePropertyAlignmentVolume(FoundTool,1.,2.0,3.0,4.0));
00672 std::string t = r.getResponseString();
00673 IPP_UTEST_ASSERT_EQUALS(t,"00025 # FoundTool.AlignmentVolume(SPH, 1., 2., 3., 4.)"IPP_END_STRING);
00674 recheck_with_parser(r);
00675 }
00676
00677 }
00678 void ippResponseTestCase::testToolIdResponse()
00679 {
00680 ippMemoryLeakDetector _leakDetector;
00681 {
00682
00683
00684 ippGetPropResponse r(25,CommandTag);
00685 r.append(new ippOnePropertyId(Tool,"<somexml/>"));
00686 std::string t = r.getResponseString();
00687 const std::string expected_String="00025 # Tool.Id(\"<somexml/>\")"IPP_END_STRING;
00688 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00689 recheck_with_parser(r);
00690 }
00691 {
00692
00693
00694
00695
00696 ippGetPropResponse r(25,CommandTag);
00697 r.append(new ippOnePropertyId(FoundTool,"<somexml/>"));
00698 std::string t = r.getResponseString();
00699 const std::string expected_String="00025 # FoundTool.Id(\"<somexml/>\")"IPP_END_STRING;
00700 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00701 recheck_with_parser(r);
00702 }
00703 }
00704 void ippResponseTestCase::testToolNameResponse()
00705 {
00706 ippMemoryLeakDetector _leakDetector;
00707 {
00708
00709
00710 ippGetPropResponse r(25,CommandTag);
00711 r.append(new ippOnePropertyName(Tool,"blah"));
00712 std::string t = r.getResponseString();
00713 const std::string expected_String="00025 # Tool.Name(\"blah\")"IPP_END_STRING;
00714 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00715 recheck_with_parser(r);
00716 }
00717 {
00718
00719
00720
00721
00722 ippGetPropResponse r(25,CommandTag);
00723 r.append(new ippOnePropertyName(FoundTool,"blah"));
00724 std::string t = r.getResponseString();
00725 const std::string expected_String="00025 # FoundTool.Name(\"blah\")"IPP_END_STRING;
00726 IPP_UTEST_ASSERT_EQUALS(t,expected_String);
00727 recheck_with_parser(r);
00728 }
00729 }
00730
00731 #include "ippdme/misc/ippPropDefinition.h"
00732 void ippResponseTestCase::testfindPropertyDefinition()
00733 {
00734 const ippPropDefinition* d1 = findPropertyDefinition( ippProp(FoundTool));
00735 IPP_UTEST_ASSERT(d1 && d1->_keyword == FoundTool);
00736 const ippPropDefinition* d2 = findPropertyDefinition( ippProp(Tool));
00737 IPP_UTEST_ASSERT(d2 && d2->_keyword == Tool);
00738 const ippPropDefinition* d3 = findPropertyDefinition( ippProp(Part));
00739 IPP_UTEST_ASSERT(d3 && d3->_keyword == Part);
00740 const ippPropDefinition* d4 = findPropertyDefinition( ippProp(FoundTool,Id));
00741 IPP_UTEST_ASSERT(d4 && d4->_keyword == Id);
00742 const ippPropDefinition* d5 = findPropertyDefinition( ippProp(Tool,PtMeasPar));
00743 IPP_UTEST_ASSERT(d5 && d5->_keyword == PtMeasPar);
00744 const ippPropDefinition* d6 = findPropertyDefinition( ippProp(Part,Temperature));
00745 IPP_UTEST_ASSERT(d6 && d6->_keyword == Temperature);
00746
00747 }
00748
00749 #include "ippdme/Command/ippEnumAllPropCommand.h"
00750 void ippResponseTestCase::testGenerateEnumAllPropResponses()
00751 {
00752 {
00753 ippEnumAllPropCommandConstPtr cmd = new ippEnumAllPropCommand(25,ippProp(FoundTool,PtMeasPar));
00754 ippResponseList list;
00755 GenerateEnumAllPropResponses(cmd,list);
00756 if (0) {
00757 std::cout << " command : " << cmd->getCommandString() << std::endl;
00758 for (ippResponseList::iterator p = list.begin();p!=list.end();p++) {
00759 std::cout << " " << (*p)->getResponseString() << std::endl;
00760 }
00761 }
00762
00763 std::string t [] ={
00764 "00025 # \"Speed\", \"Property\"\r\n",
00765 "00025 # \"Speed\", \"Number\"\r\n",
00766 "00025 # \"Speed.Act\", \"Number\"\r\n",
00767 "00025 # \"Speed.Def\", \"Number\"\r\n",
00768 "00025 # \"Speed.Max\", \"Number\"\r\n",
00769 "00025 # \"Speed.Min\", \"Number\"\r\n",
00770 "00025 # \"Accel\", \"Property\"\r\n",
00771 "00025 # \"Accel\", \"Number\"\r\n",
00772 "00025 # \"Accel.Act\", \"Number\"\r\n",
00773 "00025 # \"Accel.Def\", \"Number\"\r\n",
00774 "00025 # \"Accel.Max\", \"Number\"\r\n",
00775 "00025 # \"Accel.Min\", \"Number\"\r\n",
00776 "00025 # \"Approach\", \"Property\"\r\n",
00777 "00025 # \"Approach\", \"Number\"\r\n",
00778 "00025 # \"Approach.Act\", \"Number\"\r\n",
00779 "00025 # \"Approach.Def\", \"Number\"\r\n",
00780 "00025 # \"Approach.Max\", \"Number\"\r\n",
00781 "00025 # \"Approach.Min\", \"Number\"\r\n",
00782 "00025 # \"Retract\", \"Property\"\r\n",
00783 "00025 # \"Retract\", \"Number\"\r\n",
00784 "00025 # \"Retract.Act\", \"Number\"\r\n",
00785 "00025 # \"Retract.Def\", \"Number\"\r\n",
00786 "00025 # \"Retract.Max\", \"Number\"\r\n",
00787 "00025 # \"Retract.Min\", \"Number\"\r\n",
00788 "00025 # \"Search\", \"Property\"\r\n",
00789 "00025 # \"Search\", \"Number\"\r\n",
00790 "00025 # \"Search.Act\", \"Number\"\r\n",
00791 "00025 # \"Search.Def\", \"Number\"\r\n",
00792 "00025 # \"Search.Max\", \"Number\"\r\n",
00793 "00025 # \"Search.Min\", \"Number\"\r\n",
00794 };
00795 {
00796 size_t nb = sizeof(t)/sizeof(t[0]);
00797 IPP_UTEST_ASSERT_EQUALS(list.size(),nb);
00798 for (size_t i=0;i<std::min(nb,list.size());i++) {
00799 IPP_UTEST_ASSERT_EQUALS(list[i]->getResponseString(),t[i]);
00800 }
00801 }
00802
00803
00804
00805 }
00806 {
00807 ippEnumAllPropCommandConstPtr cmd = new ippEnumAllPropCommand(25,ippProp(FoundTool));
00808 ippResponseList list;
00809 GenerateEnumAllPropResponses(cmd,list);
00810 if (0) {
00811 std::cout << " command : " << cmd->getCommandString() << std::endl;
00812 for (ippResponseList::iterator p = list.begin();p!=list.end();p++) {
00813 std::cout << " " << (*p)->getResponseString() << std::endl;
00814 }
00815 }
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833 }
00834 {
00835 ippEnumAllPropCommandConstPtr cmd = new ippEnumAllPropCommand(25,ippProp(Tool,ScanPar));
00836 ippResponseList list;
00837 GenerateEnumAllPropResponses(cmd,list);
00838 if (0) {
00839 std::cout << " command : " << cmd->getCommandString() << std::endl;
00840 for (ippResponseList::iterator p = list.begin();p!=list.end();p++) {
00841 std::cout << " " << (*p)->getResponseString() << std::endl;
00842 }
00843 }
00844 }
00845 {
00846 ippEnumAllPropCommandConstPtr cmd = new ippEnumAllPropCommand(25,ippProp(Part));
00847 ippResponseList list;
00848 GenerateEnumAllPropResponses(cmd,list);
00849 if (0) {
00850 std::cout << " command : " << cmd->getCommandString() << std::endl;
00851 for (ippResponseList::iterator p = list.begin();p!=list.end();p++) {
00852 std::cout << " " << (*p)->getResponseString() << std::endl;
00853 }
00854 }
00855 std::string t [] ={
00856 "00025 # \"Temperature\", \"Number\"\r\n",
00857 "00025 # \"XPanCoefficient\", \"Number\"\r\n",
00858 "00025 # \"Approach\", \"Property\"\r\n",
00859 "00025 # \"Approach\", \"Number\"\r\n",
00860 "00025 # \"Approach.Act\", \"Number\"\r\n",
00861 "00025 # \"Approach.Def\", \"Number\"\r\n",
00862 "00025 # \"Approach.Max\", \"Number\"\r\n",
00863 "00025 # \"Approach.Min\", \"Number\"\r\n",
00864 "00025 # \"Search\", \"Property\"\r\n",
00865 "00025 # \"Search\", \"Number\"\r\n",
00866 "00025 # \"Search.Act\", \"Number\"\r\n",
00867 "00025 # \"Search.Def\", \"Number\"\r\n",
00868 "00025 # \"Search.Max\", \"Number\"\r\n",
00869 "00025 # \"Search.Min\", \"Number\"\r\n",
00870 };
00871 {
00872 size_t nb = sizeof(t)/sizeof(t[0]);
00873 IPP_UTEST_ASSERT_EQUALS(list.size(),nb);
00874 for (size_t i=0;i<std::min(nb,list.size());i++) {
00875 IPP_UTEST_ASSERT_EQUALS(list[i]->getResponseString(),t[i]);
00876 }
00877 }
00878
00879
00880 }
00881 }
00882 #include "ippdme/Command/ippEnumPropCommand.h"
00883 void ippResponseTestCase::testGenerateEnumPropResponses()
00884 {
00885 {
00886 ippEnumPropCommandConstPtr cmd = new ippEnumPropCommand(25,ippProp(FoundTool,PtMeasPar));
00887 ippResponseList list;
00888 GenerateEnumPropResponses(cmd,list);
00889 if (0) {
00890 std::cout << " command : " << cmd->getCommandString() << std::endl;
00891 for (ippResponseList::iterator p = list.begin();p!=list.end();p++) {
00892 std::cout << " " << (*p)->getResponseString() << std::endl;
00893 }
00894 }
00895 IPP_UTEST_ASSERT_EQUALS(list.size(),10U);
00896 const std::string t1 = "00025 # \"Speed\", \"Property\"\r\n";
00897 IPP_UTEST_ASSERT_EQUALS(list.at(0)->getResponseString(),t1);
00898 const std::string t2 = "00025 # \"Speed\", \"Number\"\r\n";
00899 IPP_UTEST_ASSERT_EQUALS(list.at(1)->getResponseString(),t2);
00900 const std::string t3 = "00025 # \"Accel\", \"Property\"\r\n";
00901 IPP_UTEST_ASSERT_EQUALS(list.at(2)->getResponseString(),t3);
00902 const std::string t4 = "00025 # \"Accel\", \"Number\"\r\n";
00903 IPP_UTEST_ASSERT_EQUALS(list.at(3)->getResponseString(),t4);
00904 const std::string t5 = "00025 # \"Approach\", \"Property\"\r\n";
00905 IPP_UTEST_ASSERT_EQUALS(list.at(4)->getResponseString(),t5);
00906 const std::string t6 = "00025 # \"Approach\", \"Number\"\r\n";
00907 IPP_UTEST_ASSERT_EQUALS(list.at(5)->getResponseString(),t6);
00908 const std::string t7 = "00025 # \"Retract\", \"Property\"\r\n";
00909 IPP_UTEST_ASSERT_EQUALS(list.at(6)->getResponseString(),t7);
00910 const std::string t8 = "00025 # \"Retract\", \"Number\"\r\n";
00911 IPP_UTEST_ASSERT_EQUALS(list.at(7)->getResponseString(),t8);
00912 const std::string t9 = "00025 # \"Search\", \"Property\"\r\n";
00913 IPP_UTEST_ASSERT_EQUALS(list.at(8)->getResponseString(),t9);
00914 const std::string t10 = "00025 # \"Search\", \"Number\"\r\n";
00915 IPP_UTEST_ASSERT_EQUALS(list.at(9)->getResponseString(),t10);
00916
00917 }
00918 }