From e089c18f91a345e8bf9edd8864bbde9b8555548a Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Mon, 9 Sep 2024 17:44:24 +0200 Subject: add some more tests --- test/it_pipe.t | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/it_pipe.t b/test/it_pipe.t index 0a36d1c..106d372 100755 --- a/test/it_pipe.t +++ b/test/it_pipe.t @@ -31,6 +31,22 @@ is(iterator_to_array((new it_pipe(['data' => ["a b\tb", "1\t2"]]))->cols('c')), # askey() is(json_encode((new it_pipe(['data' => "a\nb\n"]))->askey()), '{"a":true,"b":true}'); +# keyval() +is(json_encode((new it_pipe(['data' => "a\tA\nb\tB\n"]))->keyval()), '{"a":"A","b":"B"}'); +is(json_encode((new it_pipe(['data' => "a,A\nb,B\n"]))->keyval(",")), '{"a":"A","b":"B"}'); + +# swap() +is(json_encode((new it_pipe(['data' => "a\tA\nb\tB\n"]))->swap()->lines), '["A\ta","B\tb"]'); +is(json_encode((new it_pipe(['data' => "a,A\nb,B\n"]))->swap(',')->lines), '["A,a","B,b"]'); + +# cut() +is(json_encode((new it_pipe(['data' => "a\tA\t1\nb\tB\t2\n"]))->cut('0,2')->lines), '["a\t1","b\t2"]'); +is(json_encode((new it_pipe(['data' => "a\tA\t1\nb\tB\t2\n"]))->cut('2,0')->lines), '["1\ta","2\tb"]'); +is(json_encode((new it_pipe(['data' => "a\tA\t1\nb\tB\t2\n"]))->cut('1')->lines), '["A","B"]'); +is(json_encode((new it_pipe(['data' => "a,A,1\nb,B,2\n"]))->cut('0,2', ',')->lines), '["a,1","b,2"]'); +is(json_encode((new it_pipe(['data' => "a,A,1\nb,B,2\n"]))->cut('2,0', ',')->lines), '["1,a","2,b"]'); +is(json_encode((new it_pipe(['data' => "a,A,1\nb,B,2\n"]))->cut('1', ',')->lines), '["A","B"]'); + # __call() generic funcs is((new it_pipe(['data' => [" a a "]]))->trim()->lines[0], "a a"); is((new it_pipe(['data' => [" a a "]]))->it__match('\w', ['all' => true])->lines[0], ["a", "a"], "test argument in second pos"); -- cgit v1.2.3