X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=docs%2F4_APIs_and_Services%2F4.4_AGL_Test_Framework%2F5_Reference%2F4_LuaUnit_Assertion_Functions%2F6_Table_Assertions.md;fp=docs%2F4_APIs_and_Services%2F4.4_AGL_Test_Framework%2F5_Reference%2F4_LuaUnit_Assertion_Functions%2F6_Table_Assertions.md;h=ab6d1b23a6594e509ad0c277358e7bfcd7b103a1;hb=4aad369c9728061c97b3de792286e743ee884b09;hp=0000000000000000000000000000000000000000;hpb=619a7e48085be1538c3b01eb93dcb9dc95bf0436;p=AGL%2Fdocumentation.git diff --git a/docs/4_APIs_and_Services/4.4_AGL_Test_Framework/5_Reference/4_LuaUnit_Assertion_Functions/6_Table_Assertions.md b/docs/4_APIs_and_Services/4.4_AGL_Test_Framework/5_Reference/4_LuaUnit_Assertion_Functions/6_Table_Assertions.md new file mode 100644 index 0000000..ab6d1b2 --- /dev/null +++ b/docs/4_APIs_and_Services/4.4_AGL_Test_Framework/5_Reference/4_LuaUnit_Assertion_Functions/6_Table_Assertions.md @@ -0,0 +1,28 @@ +--- +edit_link: '' +title: Table Assertions +origin_url: >- + https://git.automotivelinux.org/apps/app-afb-test/plain/docs/Reference/LuaUnitAssertionFunctions/6_TableAssertions.md?h=master +--- + + + +# Table assertions + +* **_AFT.assertItemsEquals(actual, expected)** + + Assert that two tables contain the same items, irrespective of their keys. + + This function is practical for example if you want to compare two lists but + where items are not in the same order: + +```lua + luaunit.assertItemsEquals( {1,2,3}, {3,2,1} ) -- assertion succeeds +``` + The comparison is not recursive on the items: if any of the items are tables, + they are compared using table equality (like as in assertEquals() ), where the + key matters. + +```lua + luaunit.assertItemsEquals( {1,{2,3},4}, {4,{3,2,},1} ) -- assertion fails because {2,3} ~= {3,2} +```