diff options
Diffstat (limited to 'test/it_pipe.t')
-rwxr-xr-x | test/it_pipe.t | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/it_pipe.t b/test/it_pipe.t new file mode 100755 index 0000000..16e2c29 --- /dev/null +++ b/test/it_pipe.t @@ -0,0 +1,18 @@ +#!/www/server/bin/php +<?php + +# csv() +is(json_encode((new it_pipe(['data' => ["a\tb", "1\t2"]]))->csv()), '[{"a":"1","b":"2"}]'); +is(json_encode((new it_pipe(['data' => ["a;b", "1;2"]]))->csv()), '[{"a":"1","b":"2"}]'); +is(json_encode((new it_pipe(['data' => ["a,b", "1,2"]]))->csv()), '[{"a":"1","b":"2"}]'); +is(json_encode((new it_pipe(['data' => ["\t", "1\t2"]]))->csv()), '[{"field0":"1","field1":"2"}]'); +is(json_encode((new it_pipe(['data' => ["a\tb", "1\t2"]]))->csv("c,d")), '[{"c":"1","d":"2"}]'); +is(json_encode((new it_pipe(['data' => ["a\tb", "1\t2"]]))->csv(['forceschema' => "c,d"])), '[{"c":"1","d":"2"}]'); +is(json_encode((new it_pipe(['data' => ["a b\tb", "1\t2"]]))->csv(['fixcolnames' => true])), '[{"a_b":"1","b":"2"}]'); + +# askey() +is(json_encode((new it_pipe(['data' => "a\nb\n"]))->askey()), '{"a":true,"b":true}'); + +# __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"); |