@@ -804,6 +804,34 @@ TEST_F(LooksBlocksTest, SwitchCostumeTo_NegativeOutOfRangeNumberIndex)
804
804
ASSERT_EQ (sprite->costumeIndex (), 1 );
805
805
}
806
806
807
+ TEST_F (LooksBlocksTest, SwitchCostumeTo_InvalidNumberIndex)
808
+ {
809
+ auto sprite = std::make_shared<Sprite>();
810
+ auto costume1 = std::make_shared<Costume>(" costume1" , " a" , " png" );
811
+ auto numberCostume = std::make_shared<Costume>(" 3" , " b" , " png" );
812
+ auto testCostume = std::make_shared<Costume>(" test" , " c" , " svg" );
813
+ sprite->addCostume (costume1);
814
+ sprite->addCostume (numberCostume);
815
+ sprite->addCostume (testCostume);
816
+
817
+ ScriptBuilder builder (m_extension.get (), m_engine, sprite);
818
+
819
+ builder.addBlock (" looks_switchcostumeto" );
820
+ builder.addValueInput (" COSTUME" , std::numeric_limits<double >::quiet_NaN ());
821
+ builder.addBlock (" looks_switchcostumeto" );
822
+ builder.addValueInput (" COSTUME" , std::numeric_limits<double >::infinity ());
823
+ builder.addBlock (" looks_switchcostumeto" );
824
+ builder.addValueInput (" COSTUME" , -std::numeric_limits<double >::infinity ());
825
+ builder.build ();
826
+
827
+ builder.run ();
828
+ ASSERT_EQ (sprite->costumeIndex (), 0 );
829
+
830
+ sprite->setCostumeIndex (2 );
831
+ builder.run ();
832
+ ASSERT_EQ (sprite->costumeIndex (), 0 );
833
+ }
834
+
807
835
TEST_F (LooksBlocksTest, SwitchCostumeTo_StringIndex)
808
836
{
809
837
auto sprite = std::make_shared<Sprite>();
0 commit comments