summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Gass2024-09-09 17:44:24 +0200
committerNathan Gass2024-09-09 17:44:24 +0200
commite089c18f91a345e8bf9edd8864bbde9b8555548a (patch)
treee48a5f1e32dac1f30a01a6525e04fbfeab5beae0
parentb56062ede648745047878fea02d6392de5c90e80 (diff)
downloaditools-e089c18f91a345e8bf9edd8864bbde9b8555548a.tar.gz
itools-e089c18f91a345e8bf9edd8864bbde9b8555548a.tar.bz2
itools-e089c18f91a345e8bf9edd8864bbde9b8555548a.zip
add some more tests
-rwxr-xr-xtest/it_pipe.t16
1 files changed, 16 insertions, 0 deletions
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");