From c9dabbd271afb8ac85009cd220f22a20a4373490 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Thu, 11 Nov 2010 16:25:45 +0000 Subject: add reorder argument and tests to it::filter_keys --- tests/it.t | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/it.t b/tests/it.t index 475ff25..0fa84f2 100755 --- a/tests/it.t +++ b/tests/it.t @@ -199,4 +199,21 @@ is( array( array( 'word1', 'wörd2', 'word_3' ), array( '12', '3', '4' ) ), "test all=>1,pattern_order=>1" ); + + +# it::filter_keys tests + +$data = array('a' => 1, 'b' => 2, 'c' => 3); +is(it::filter_keys($data, 'a'), array('a' => 1), "select one key"); +is(it::filter_keys($data, array('a', 'b')), array('a' => 1, 'b' => 2), "select two keys with array"); +is(it::filter_keys($data, 'a,b'), array('a' => 1, 'b' => 2), "select two keys with string"); +is( + array_keys(it::filter_keys($data, 'b,a')), + array('a', 'b'), + "keep order of data array per default"); +is( + array_keys(it::filter_keys($data, 'b,a', array('reorder' => true))), + array('b', 'a'), + "reorder with given key order"); + ?> -- cgit v1.2.3