@@ -649,6 +649,30 @@ TEST(SpriteTest, TouchingSprite)
649649
650650 EXPECT_CALL (iface, touchingClones).WillOnce (Return (true ));
651651 ASSERT_TRUE (sprite.touchingSprite (&another));
652+
653+ SpriteHandlerMock iface2;
654+ EXPECT_CALL (iface2, init);
655+ another.setInterface (&iface2);
656+ clones.erase (clones.begin ()); // the sprite cannot touch itself
657+
658+ EXPECT_CALL (iface2, touchingClones (_)).WillOnce (WithArgs<0 >(Invoke ([&clones, &actualClones](const std::vector<Sprite *> &candidates) {
659+ actualClones = candidates;
660+ return false ;
661+ })));
662+ ASSERT_FALSE (another.touchingSprite (&another));
663+ ASSERT_EQ (clones, actualClones);
664+ clones.insert (clones.begin (), &another);
665+
666+ SpriteHandlerMock iface3;
667+ EXPECT_CALL (iface3, init);
668+ clone2->setInterface (&iface3);
669+ clones.erase (clones.begin () + 2 ); // the clone cannot touch itself, but can touch the sprite (clone root)
670+ EXPECT_CALL (iface3, touchingClones (_)).WillOnce (WithArgs<0 >(Invoke ([&clones, &actualClones](const std::vector<Sprite *> &candidates) {
671+ actualClones = candidates;
672+ return false ;
673+ })));
674+ ASSERT_FALSE (clone2->touchingSprite (clone2.get ()));
675+ ASSERT_EQ (clones, actualClones);
652676}
653677
654678TEST (SpriteTest, TouchingPoint)
0 commit comments