56 #include "unity_fixture.h"
61 #include "smTestAct.h"
62 #include "MocksmTestAct.h"
63 #include "Mockrkhassert.h"
80 typedef struct StateMachine
86 typedef struct Composite
94 TEST_GROUP(transition);
100 TEST_SETUP(transition)
103 MocksmTestAct_Init();
135 TEST_TEAR_DOWN(transition)
140 MocksmTestAct_Verify();
141 MocksmTestAct_Destroy();
151 TEST(transition, firstStateAfterInit)
155 sm_init_expect(RKH_STATE_CAST(&waiting));
156 sm_enstate_expect(RKH_STATE_CAST(&waiting));
157 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
161 p = unitrazer_getLastOut();
162 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
165 TEST(transition, simpleToSimpleAtEqualLevel)
170 RKH_STATE_CAST(&s1), RKH_STATE_CAST(0)
174 RKH_STATE_CAST(&s1), RKH_STATE_CAST(0)
178 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
181 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
182 smTest_xS0_Expect(
RKH_CAST(SmTest, smTest));
183 smTest_tr11_Expect(
RKH_CAST(SmTest, smTest), &evA);
184 smTest_nS1_Expect(
RKH_CAST(SmTest, smTest));
186 setProfile(smTest, RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s0),
188 entryStates, exitStates, RKH_STATE_CAST(&s1), 1,
189 TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evA,
190 RKH_STATE_CAST(&s0));
194 p = unitrazer_getLastOut();
195 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
198 TEST(transition, simpleToSimpleFromHighToLowLevel)
203 RKH_STATE_CAST(&s21), RKH_STATE_CAST(0)
207 RKH_STATE_CAST(&s2), RKH_STATE_CAST(&s21), RKH_STATE_CAST(0)
211 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
214 smTest_xS0_Expect(
RKH_CAST(SmTest, smTest));
215 smTest_tr12_Expect(
RKH_CAST(SmTest, smTest), &evB);
216 smTest_nS2_Expect(
RKH_CAST(SmTest, smTest));
217 smTest_nS21_Expect(
RKH_CAST(SmTest, smTest));
219 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
220 setProfile(smTest, RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s0),
222 entryStates, exitStates, RKH_STATE_CAST(&s21), 1,
223 TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evB,
224 RKH_STATE_CAST(&s0));
228 p = unitrazer_getLastOut();
229 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
232 TEST(transition, simpleToSimpleFromLowToHighLevel)
237 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
241 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
245 RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s2), RKH_STATE_CAST(0)
248 smTest_xS21_Expect(
RKH_CAST(SmTest, smTest));
249 smTest_xS2_Expect(
RKH_CAST(SmTest, smTest));
250 smTest_tr13_Expect(
RKH_CAST(SmTest, smTest), &evB);
251 smTest_nS0_Expect(
RKH_CAST(SmTest, smTest));
253 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
254 setProfile(smTest, RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s21),
256 entryStates, exitStates, RKH_STATE_CAST(&s0), 1,
257 TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evB,
258 RKH_STATE_CAST(&s21));
262 p = unitrazer_getLastOut();
263 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
266 TEST(transition, simpleToCompositeAtEqualLevel)
271 RKH_STATE_CAST(&s2), RKH_STATE_CAST(0)
275 RKH_STATE_CAST(&s2), RKH_STATE_CAST(&s21), RKH_STATE_CAST(0)
279 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
282 smTest_xS0_Expect(
RKH_CAST(SmTest, smTest));
283 smTest_tr21_Expect(
RKH_CAST(SmTest, smTest), &evC);
284 smTest_nS2_Expect(
RKH_CAST(SmTest, smTest));
285 smTest_iS2_Expect(
RKH_CAST(SmTest, smTest));
286 smTest_nS21_Expect(
RKH_CAST(SmTest, smTest));
288 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
289 setProfile(smTest, RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s0),
291 entryStates, exitStates, RKH_STATE_CAST(&s21), 1,
292 TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evC,
293 RKH_STATE_CAST(&s0));
297 p = unitrazer_getLastOut();
298 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
301 TEST(transition, simpleToCompositeFromHighToLowLevel)
306 RKH_STATE_CAST(&s22), RKH_STATE_CAST(0)
310 RKH_STATE_CAST(&s2), RKH_STATE_CAST(&s22), RKH_STATE_CAST(&s221),
311 RKH_STATE_CAST(&s2211), RKH_STATE_CAST(0)
315 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
318 smTest_xS0_Expect(
RKH_CAST(SmTest, smTest));
319 smTest_tr22_Expect(
RKH_CAST(SmTest, smTest), &evD);
320 smTest_nS2_Expect(
RKH_CAST(SmTest, smTest));
321 smTest_nS22_Expect(
RKH_CAST(SmTest, smTest));
322 smTest_iS22_Expect(
RKH_CAST(SmTest, smTest));
323 smTest_nS221_Expect(
RKH_CAST(SmTest, smTest));
324 smTest_iS221_Expect(
RKH_CAST(SmTest, smTest));
325 smTest_nS2211_Expect(
RKH_CAST(SmTest, smTest));
327 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
328 setProfile(smTest, RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s0),
330 entryStates, exitStates, RKH_STATE_CAST(&s2211), 1,
331 TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evD,
332 RKH_STATE_CAST(&s0));
336 p = unitrazer_getLastOut();
337 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
340 TEST(transition, simpleToCompositeFromLowToHighLevel)
345 RKH_STATE_CAST(&s2), RKH_STATE_CAST(0)
349 RKH_STATE_CAST(&s21), RKH_STATE_CAST(0)
353 RKH_STATE_CAST(&s21), RKH_STATE_CAST(0)
356 smTest_xS21_Expect(
RKH_CAST(SmTest, smTest));
357 smTest_tr23_Expect(
RKH_CAST(SmTest, smTest), &evC);
358 smTest_iS2_Expect(
RKH_CAST(SmTest, smTest));
359 smTest_nS21_Expect(
RKH_CAST(SmTest, smTest));
361 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
362 setProfile(smTest, RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s21),
364 entryStates, exitStates, RKH_STATE_CAST(&s21), 1,
365 TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evC,
366 RKH_STATE_CAST(&s21));
370 p = unitrazer_getLastOut();
371 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
374 TEST(transition, compositeToSimpleAtEqualLevel)
379 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
383 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
387 RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s2), RKH_STATE_CAST(0)
390 smTest_xS21_Expect(
RKH_CAST(SmTest, smTest));
391 smTest_xS2_Expect(
RKH_CAST(SmTest, smTest));
392 smTest_tr31_Expect(
RKH_CAST(SmTest, smTest), &evA);
393 smTest_nS0_Expect(
RKH_CAST(SmTest, smTest));
395 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
396 setProfile(smTest, RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s2),
398 entryStates, exitStates, RKH_STATE_CAST(&s0), 1,
399 TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evA,
400 RKH_STATE_CAST(&s21));
404 p = unitrazer_getLastOut();
405 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
408 TEST(transition, compositeToSimpleFromHighToLowLevel)
413 RKH_STATE_CAST(&s21), RKH_STATE_CAST(0)
417 RKH_STATE_CAST(&s21), RKH_STATE_CAST(0)
421 RKH_STATE_CAST(&s21), RKH_STATE_CAST(0)
424 smTest_xS21_Expect(
RKH_CAST(SmTest, smTest));
425 smTest_tr32_Expect(
RKH_CAST(SmTest, smTest), &evD);
426 smTest_nS21_Expect(
RKH_CAST(SmTest, smTest));
428 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
429 setProfile(smTest, RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s2),
431 entryStates, exitStates, RKH_STATE_CAST(&s21), 1,
432 TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evD,
433 RKH_STATE_CAST(&s21));
437 p = unitrazer_getLastOut();
438 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
441 TEST(transition, loopSimpleStateOnTop)
446 RKH_STATE_CAST(&s1), RKH_STATE_CAST(0)
450 RKH_STATE_CAST(&s1), RKH_STATE_CAST(0)
454 RKH_STATE_CAST(&s1), RKH_STATE_CAST(0)
457 smTest_xS1_Expect(
RKH_CAST(SmTest, smTest));
458 smTest_tr53_Expect(
RKH_CAST(SmTest, smTest), &evA);
459 smTest_nS1_Expect(
RKH_CAST(SmTest, smTest));
461 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
462 setProfile(smTest, RKH_STATE_CAST(&s1), RKH_STATE_CAST(&s1),
464 entryStates, exitStates, RKH_STATE_CAST(&s1), 1,
465 TRN_NOT_INTERNAL, INIT_STATE_MACHINE, &evA,
466 RKH_STATE_CAST(&s1));
470 p = unitrazer_getLastOut();
471 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
474 TEST(transition, loopNestedSimpleState)
479 RKH_STATE_CAST(&s31), RKH_STATE_CAST(0)
483 RKH_STATE_CAST(&s31), RKH_STATE_CAST(0)
487 RKH_STATE_CAST(&s31), RKH_STATE_CAST(0)
490 smTest_xS31_Expect(
RKH_CAST(SmTest, smTest));
491 smTest_tr52_Expect(
RKH_CAST(SmTest, smTest), &evD);
492 smTest_nS31_Expect(
RKH_CAST(SmTest, smTest));
494 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
495 setProfile(smTest, RKH_STATE_CAST(&s31), RKH_STATE_CAST(&s31),
496 targetStates, entryStates, exitStates,
497 RKH_STATE_CAST(&s31), 1, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
498 &evD, RKH_STATE_CAST(&s31));
502 p = unitrazer_getLastOut();
503 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
506 TEST(transition, loopCompositeStateOnTop)
511 RKH_STATE_CAST(&s3), RKH_STATE_CAST(0)
515 RKH_STATE_CAST(&s31), RKH_STATE_CAST(0)
519 RKH_STATE_CAST(&s31), RKH_STATE_CAST(0)
522 smTest_xS31_Expect(
RKH_CAST(SmTest, smTest));
523 smTest_tr51_Expect(
RKH_CAST(SmTest, smTest), &evA);
524 smTest_iS3_Expect(
RKH_CAST(SmTest, smTest));
525 smTest_nS31_Expect(
RKH_CAST(SmTest, smTest));
527 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
528 setProfile(smTest, RKH_STATE_CAST(&s31), RKH_STATE_CAST(&s3),
529 targetStates, entryStates, exitStates,
530 RKH_STATE_CAST(&s31), 1, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
531 &evA, RKH_STATE_CAST(&s31));
535 p = unitrazer_getLastOut();
536 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
539 TEST(transition, loopNestedCompositeState)
544 RKH_STATE_CAST(&s22), RKH_STATE_CAST(0)
548 RKH_STATE_CAST(&s221), RKH_STATE_CAST(&s2211), RKH_STATE_CAST(0)
552 RKH_STATE_CAST(&s2211), RKH_STATE_CAST(&s221), RKH_STATE_CAST(0)
555 smTest_xS2211_Expect(
RKH_CAST(SmTest, smTest));
556 smTest_xS221_Expect(
RKH_CAST(SmTest, smTest));
557 smTest_tr54_Expect(
RKH_CAST(SmTest, smTest), &evD);
558 smTest_iS22_Expect(
RKH_CAST(SmTest, smTest));
559 smTest_nS221_Expect(
RKH_CAST(SmTest, smTest));
560 smTest_iS221_Expect(
RKH_CAST(SmTest, smTest));
561 smTest_nS2211_Expect(
RKH_CAST(SmTest, smTest));
563 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
564 setProfile(smTest, RKH_STATE_CAST(&s2211), RKH_STATE_CAST(&s22),
565 targetStates, entryStates, exitStates,
566 RKH_STATE_CAST(&s2211), 1, TRN_NOT_INTERNAL,
567 INIT_STATE_MACHINE, &evD, RKH_STATE_CAST(&s2211));
571 p = unitrazer_getLastOut();
572 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
575 TEST(transition, compositeToSimpleFromLowToHighLevel)
580 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
584 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
588 RKH_STATE_CAST(&s221), RKH_STATE_CAST(&s22), RKH_STATE_CAST(&s2),
592 smTest_xS221_Expect(
RKH_CAST(SmTest, smTest));
593 smTest_xS22_Expect(
RKH_CAST(SmTest, smTest));
594 smTest_xS2_Expect(
RKH_CAST(SmTest, smTest));
595 smTest_tr33_Expect(
RKH_CAST(SmTest, smTest), &evB);
596 smTest_nS0_Expect(
RKH_CAST(SmTest, smTest));
598 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
599 setProfile(smTest, RKH_STATE_CAST(&s221), RKH_STATE_CAST(&s22),
600 targetStates, entryStates, exitStates,
601 RKH_STATE_CAST(&s0), 1, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
602 &evB, RKH_STATE_CAST(&s221));
606 p = unitrazer_getLastOut();
607 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
610 TEST(transition, compositeToCompositeAtEqualLevel)
615 RKH_STATE_CAST(&s2), RKH_STATE_CAST(0)
619 RKH_STATE_CAST(&s2), RKH_STATE_CAST(&s21), RKH_STATE_CAST(0)
623 RKH_STATE_CAST(&s31), RKH_STATE_CAST(&s3), RKH_STATE_CAST(0)
626 smTest_xS31_Expect(
RKH_CAST(SmTest, smTest));
627 smTest_xS3_Expect(
RKH_CAST(SmTest, smTest));
628 smTest_tr41_Expect(
RKH_CAST(SmTest, smTest), &evB);
629 smTest_nS2_Expect(
RKH_CAST(SmTest, smTest));
630 smTest_iS2_Expect(
RKH_CAST(SmTest, smTest));
631 smTest_nS21_Expect(
RKH_CAST(SmTest, smTest));
633 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
634 setProfile(smTest, RKH_STATE_CAST(&s31), RKH_STATE_CAST(&s3),
635 targetStates, entryStates, exitStates,
636 RKH_STATE_CAST(&s21), 1, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
637 &evB, RKH_STATE_CAST(&s31));
641 p = unitrazer_getLastOut();
642 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
645 TEST(transition, compositeToCompositeFromHighToLowLevel)
650 RKH_STATE_CAST(&s22), RKH_STATE_CAST(0)
654 RKH_STATE_CAST(&s2), RKH_STATE_CAST(&s22), RKH_STATE_CAST(&s221),
655 RKH_STATE_CAST(&s2211), RKH_STATE_CAST(0)
659 RKH_STATE_CAST(&s31), RKH_STATE_CAST(&s3), RKH_STATE_CAST(0)
662 smTest_xS31_Expect(
RKH_CAST(SmTest, smTest));
663 smTest_xS3_Expect(
RKH_CAST(SmTest, smTest));
664 smTest_tr42_Expect(
RKH_CAST(SmTest, smTest), &evC);
665 smTest_nS2_Expect(
RKH_CAST(SmTest, smTest));
666 smTest_nS22_Expect(
RKH_CAST(SmTest, smTest));
667 smTest_iS22_Expect(
RKH_CAST(SmTest, smTest));
668 smTest_nS221_Expect(
RKH_CAST(SmTest, smTest));
669 smTest_iS221_Expect(
RKH_CAST(SmTest, smTest));
670 smTest_nS2211_Expect(
RKH_CAST(SmTest, smTest));
672 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
673 setProfile(smTest, RKH_STATE_CAST(&s31), RKH_STATE_CAST(&s3),
674 targetStates, entryStates, exitStates,
675 RKH_STATE_CAST(&s2211), 1, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
676 &evC, RKH_STATE_CAST(&s31));
680 p = unitrazer_getLastOut();
681 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
684 TEST(transition, compositeToCompositeFromLowToHighLevel)
689 RKH_STATE_CAST(&s3), RKH_STATE_CAST(0)
693 RKH_STATE_CAST(&s3), RKH_STATE_CAST(&s31), RKH_STATE_CAST(0)
697 RKH_STATE_CAST(&s221), RKH_STATE_CAST(&s22), RKH_STATE_CAST(&s2),
701 smTest_xS221_Expect(
RKH_CAST(SmTest, smTest));
702 smTest_xS22_Expect(
RKH_CAST(SmTest, smTest));
703 smTest_xS2_Expect(
RKH_CAST(SmTest, smTest));
704 smTest_tr43_Expect(
RKH_CAST(SmTest, smTest), &evC);
705 smTest_nS3_Expect(
RKH_CAST(SmTest, smTest));
706 smTest_iS3_Expect(
RKH_CAST(SmTest, smTest));
707 smTest_nS31_Expect(
RKH_CAST(SmTest, smTest));
709 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
710 setProfile(smTest, RKH_STATE_CAST(&s221), RKH_STATE_CAST(&s22),
711 targetStates, entryStates, exitStates,
712 RKH_STATE_CAST(&s31), 1, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
713 &evC, RKH_STATE_CAST(&s221));
717 p = unitrazer_getLastOut();
718 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
721 TEST(transition, internalInSimpleState)
726 RKH_STATE_CAST(&s1), RKH_STATE_CAST(0)
737 smTest_tr14_Expect(
RKH_CAST(SmTest, smTest), &evB);
739 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
740 setProfile(smTest, RKH_STATE_CAST(&s1), RKH_STATE_CAST(&s1),
741 targetStates, entryStates, exitStates,
742 RKH_STATE_CAST(&s1), 1, TRN_INTERNAL, INIT_STATE_MACHINE,
743 &evB, RKH_STATE_CAST(&s1));
747 p = unitrazer_getLastOut();
748 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
751 TEST(transition, internalInCompositeState)
756 RKH_STATE_CAST(&s3), RKH_STATE_CAST(0)
767 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
768 smTest_tr15_Expect(
RKH_CAST(SmTest, smTest), &evE);
770 setProfile(smTest, RKH_STATE_CAST(&s31), RKH_STATE_CAST(&s3),
771 targetStates, entryStates, exitStates,
772 RKH_STATE_CAST(&s31), 1, TRN_INTERNAL, INIT_STATE_MACHINE,
773 &evE, RKH_STATE_CAST(&s31));
777 p = unitrazer_getLastOut();
778 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
781 TEST(transition, fails_EventNotFound)
785 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
787 sm_init_expect(RKH_STATE_CAST(&waiting));
788 sm_enstate_expect(RKH_STATE_CAST(&waiting));
789 sm_dch_expect(evE.e, RKH_STATE_CAST(&s1));
790 sm_evtNotFound_expect(E);
793 setState(smTest, RKH_STATE_CAST(&s1));
796 p = unitrazer_getLastOut();
797 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
800 TEST(transition, fails_GuardFalse)
804 sm_init_expect(RKH_STATE_CAST(&waiting));
805 sm_enstate_expect(RKH_STATE_CAST(&waiting));
806 sm_grdFalse_expect();
807 sm_dch_expect(evC.e, RKH_STATE_CAST(&s1));
808 sm_evtNotFound_expect(C);
810 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
811 smTest_falseGuard_ExpectAndReturn(
RKH_CAST(SmTest, smTest), &evC,
815 setState(smTest, RKH_STATE_CAST(&s1));
818 p = unitrazer_getLastOut();
819 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
822 TEST(transition, fails_ExceededHierarchicalLevel)
826 sm_init_expect(RKH_STATE_CAST(&waiting));
827 sm_enstate_expect(RKH_STATE_CAST(&waiting));
828 sm_dch_expect(evE.e, RKH_STATE_CAST(&s0));
829 sm_trn_expect(RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s22211));
830 sm_tsState_expect(RKH_STATE_CAST(&s22211));
831 sm_exHLevel_expect();
832 rkh_assert_Expect(
"rkhsm", 0);
833 rkh_assert_IgnoreArg_line();
835 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
838 setState(smTest, RKH_STATE_CAST(&s0));
841 p = unitrazer_getLastOut();
842 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
845 TEST(transition, multipleEnabledTrn_FiringFirstTrueGuard)
849 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
859 sm_grdFalse_expect();
862 setState(smTest, RKH_STATE_CAST(&s4));
865 p = unitrazer_getLastOut();
866 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
869 TEST(transition, multipleEnabledTrn_FiringFirstEmptyGuard)
873 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
882 sm_grdFalse_expect();
883 sm_grdFalse_expect();
888 sm_tsState_expect(RKH_STATE_CAST(&s4));
891 setState(smTest, RKH_STATE_CAST(&s4));
894 p = unitrazer_getLastOut();
895 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
898 TEST(transition, defaultTrnWithAssociatedEffect)
903 RKH_STATE_CAST(&s3), RKH_STATE_CAST(0)
907 RKH_STATE_CAST(&s3), RKH_STATE_CAST(&s31), RKH_STATE_CAST(0)
911 RKH_STATE_CAST(&s0), RKH_STATE_CAST(0)
914 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
915 smTest_xS0_Expect(
RKH_CAST(SmTest, smTest));
916 smTest_tr55_Expect(
RKH_CAST(SmTest, smTest), &evF);
917 smTest_nS3_Expect(
RKH_CAST(SmTest, smTest));
918 smTest_iS3_Expect(
RKH_CAST(SmTest, smTest));
919 smTest_nS31_Expect(
RKH_CAST(SmTest, smTest));
921 setProfile(smTest, RKH_STATE_CAST(&s0), RKH_STATE_CAST(&s0),
922 targetStates, entryStates, exitStates,
923 RKH_STATE_CAST(&s31), 1, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
924 &evF, RKH_STATE_CAST(&s0));
928 p = unitrazer_getLastOut();
929 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
932 TEST(transition, generatedCompletionEventBySimpleState)
937 RKH_STATE_CAST(&s5), RKH_STATE_CAST(0)
941 RKH_STATE_CAST(&s5), RKH_STATE_CAST(0)
945 RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s2), RKH_STATE_CAST(0)
949 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
950 smTest_xS21_Expect(
RKH_CAST(SmTest, smTest));
951 smTest_xS2_Expect(
RKH_CAST(SmTest, smTest));
952 smTest_nS5_Expect(
RKH_CAST(SmTest, smTest));
954 setProfile(smTest, RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s2),
955 targetStates, entryStates, exitStates,
956 RKH_STATE_CAST(&s5), 0, TRN_NOT_INTERNAL, INIT_STATE_MACHINE,
957 &evE, RKH_STATE_CAST(&s21));
960 targetStates[0] = RKH_STATE_CAST(&s4);
961 targetStates[1] = RKH_STATE_CAST(0);
962 entryStates[0] = RKH_STATE_CAST(&s4);
963 entryStates[1] = RKH_STATE_CAST(0);
964 exitStates[0] = RKH_STATE_CAST(&s5);
965 exitStates[1] = RKH_STATE_CAST(0);
967 smTest_xS5_Expect(
RKH_CAST(SmTest, smTest));
968 smTest_tr61_Expect(
RKH_CAST(SmTest, smTest), &evCompletion);
970 setProfile(smTest, NULL, RKH_STATE_CAST(&s5),
971 targetStates, entryStates, exitStates,
972 RKH_STATE_CAST(&s4), 1, TRN_NOT_INTERNAL,
973 NO_INIT_STATE_MACHINE, &evCompletion, RKH_STATE_CAST(&s5));
978 p = unitrazer_getLastOut();
979 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
982 TEST(transition, generatedCompletionEventByFinalState)
987 RKH_STATE_CAST(&s2Final), RKH_STATE_CAST(0)
991 RKH_STATE_CAST(&s2Final), RKH_STATE_CAST(0)
995 RKH_STATE_CAST(&s21), RKH_STATE_CAST(0), RKH_STATE_CAST(0)
999 smTest_init_Expect(
RKH_CAST(SmTest, smTest));
1000 smTest_xS21_Expect(
RKH_CAST(SmTest, smTest));
1002 setProfile(smTest, RKH_STATE_CAST(&s21), RKH_STATE_CAST(&s21),
1003 targetStates, entryStates, exitStates,
1004 RKH_STATE_CAST(&s2Final), 0, TRN_NOT_INTERNAL,
1005 INIT_STATE_MACHINE, &evF, RKH_STATE_CAST(&s21));
1008 targetStates[0] = RKH_STATE_CAST(&s4);
1009 targetStates[1] = RKH_STATE_CAST(0);
1010 entryStates[0] = RKH_STATE_CAST(&s4);
1011 entryStates[1] = RKH_STATE_CAST(0);
1012 exitStates[0] = RKH_STATE_CAST(&s2Final);
1013 exitStates[1] = RKH_STATE_CAST(&s2);
1014 exitStates[2] = RKH_STATE_CAST(0);
1016 smTest_xS2_Expect(
RKH_CAST(SmTest, smTest));
1017 smTest_guardS2_ExpectAndReturn(
RKH_CAST(SmTest, smTest), &evCompletion,
1019 smTest_tr60_Expect(
RKH_CAST(SmTest, smTest), &evCompletion);
1021 setProfile(smTest, NULL, RKH_STATE_CAST(&s2),
1022 targetStates, entryStates, exitStates,
1023 RKH_STATE_CAST(&s4), 1, TRN_NOT_INTERNAL,
1024 NO_INIT_STATE_MACHINE, &evCompletion, RKH_STATE_CAST(&s2Final));
1029 p = unitrazer_getLastOut();
1030 TEST_ASSERT_EQUAL(UT_PROC_SUCCESS, p->status);
1033 TEST(transition, syncDispatchingToStateMachine)
#define RKH_COMPLETION_EVENT
This macro is used to indicate the completion event.
#define RKH_FILTER_OFF_GROUP_ALL_EVENTS(grp)
Emit (enable) all events in a specific group.
#define sm_cleanup()
Return the system under test to its initial state after the test.
Describes the SMA (active object in UML).
#define RKH_TR_FWK_AO(actObj_)
Entry symbol table for active object.
Interface of unit test with Trazer application.
#define RKH_FALSE
Standard define.
#define RKH_TG_SM
State Machine group (SM)
Describes the state machine.
void rkh_sm_init(RKH_SM_T *me)
Inits a previously created state machine calling its initializing action.
#define sm_init()
Establish the preconditions to the tests.
#define RKH_TR_FWK_STATE(actObj_, stateObj_)
Entry symbol table for state object.
#define sm_verify()
Makes sure there are no unused expectations, if there are, this function causes the test to fail...
#define RKH_TE_FWK_ASSERT
Assertion expression was evaluated to false.
ruint rkh_sm_dispatch(RKH_SM_T *me, RKH_EVT_T *e)
Executes a state machine in a run-to-completation (RTC) model.
Describes the common properties of regular states (basic, composite, and submachine).
#define RKH_TRUE
Standard define.
#define RKH_CAST(_type, _obj)
Perform downcast of a reference of a base class to one of its derived classes.
#define RKH_TR_FWK_SIG(stateObj_)
Entry symbol table for event signal.
#define RKH_STATIC_EVENT(ev_obj, ev_sig)
This macro declares and initializes the event structure ev_ob with ev_sig signal number and establish...
#define RKH_FILTER_OFF_EVENT(evt)
Emit (enable) one trace event. Use the RKH_TRC_ALL_EVENTS to enable all trace events.
#define RKH_FILTER_OFF_ALL_SIGNALS()
Emmit all enabled trace events related to signals.
#define RKH_FILTER_OFF_SMA(sma)
Emmit the enabled trace events related to a specified active object.
Specifies the interface of dynamic event support.