Skip to content

Commit 425c679

Browse files
committed
libioencode/test: test iodecode() with NULL data parameter
Problem: The libioencode unit test does not test NULL data parameter. Add tests that ensure iodecode() with NULL datap parameter works and returns the expected data length.
1 parent f9c9c86 commit 425c679

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/common/libioencode/test/ioencode.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ void basic (void)
6262
&& eof == true,
6363
"iodecode returned correct info");
6464
free (data);
65+
66+
ok (iodecode (o, &stream, &rank, NULL, &len, &eof) == 0,
67+
"iodecode can be passed NULL data to query len");
68+
ok (!strcmp (stream, "stdout")
69+
&& !strcmp (rank, "[0-8]")
70+
&& len == 3
71+
&& eof == true,
72+
"iodecode returned correct info");
6573
json_decref (o);
6674

6775
ok ((o = ioencode ("stderr", "[4,5]", NULL, 0, true)) != NULL,
@@ -75,6 +83,14 @@ void basic (void)
7583
&& eof == true,
7684
"iodecode returned correct info");
7785
free (data);
86+
87+
ok (iodecode (o, &stream, &rank, NULL, &len, &eof) == 0,
88+
"iodecode can be passed NULL data to query len");
89+
ok (!strcmp (stream, "stderr")
90+
&& !strcmp (rank, "[4,5]")
91+
&& len == 0
92+
&& eof == true,
93+
"iodecode returned correct info");
7894
json_decref (o);
7995
}
8096

@@ -108,6 +124,10 @@ static void binary_data (void)
108124
ok (memcmp (data, buffer, len) == 0,
109125
"data matches");
110126
free (data);
127+
ok (iodecode (o, &stream, &rank, NULL, &len, &eof) == 0,
128+
"iodecode can be passed NULL data to query len");
129+
ok (len == sizeof (buffer),
130+
"len is correct");
111131
json_decref (o);
112132
}
113133

0 commit comments

Comments
 (0)