@@ -379,3 +379,48 @@ TEST_F(ListBlocksTest, ItemNumOfList)
379379 ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
380380 ASSERT_EQ (list->toString (), " Lorem ipsum dolor 123 true dolor" );
381381}
382+
383+ TEST_F (ListBlocksTest, LengthOfList)
384+ {
385+ auto target = std::make_shared<Sprite>();
386+
387+ auto list1 = std::make_shared<List>(" list1" , " " );
388+ list1->append (" Lorem" );
389+ list1->append (" ipsum" );
390+ list1->append (" dolor" );
391+ list1->append (123 );
392+ list1->append (true );
393+ target->addList (list1);
394+
395+ auto list2 = std::make_shared<List>(" list2" , " " );
396+ list2->append (1 );
397+ list2->append (false );
398+ target->addList (list2);
399+
400+ ScriptBuilder builder (m_extension.get (), m_engine, target);
401+
402+ auto addTest = [&builder](std::shared_ptr<List> list) {
403+ builder.addBlock (" data_lengthoflist" );
404+ builder.addEntityField (" LIST" , list);
405+ auto block = builder.takeBlock ();
406+
407+ builder.addBlock (" test_print" );
408+ builder.addObscuredInput (" STRING" , block);
409+ return builder.currentBlock ();
410+ };
411+
412+ auto block = addTest (list1);
413+ addTest (list2);
414+
415+ builder.build ();
416+
417+ static const std::string expected =
418+ " 5\n "
419+ " 2\n " ;
420+
421+ testing::internal::CaptureStdout ();
422+ builder.run ();
423+ ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
424+ ASSERT_EQ (list1->toString (), " Lorem ipsum dolor 123 true" );
425+ ASSERT_EQ (list2->toString (), " 1 false" );
426+ }
0 commit comments