diff options
author | ngie <ngie@FreeBSD.org> | 2015-11-16 02:00:12 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2015-11-16 02:00:12 +0000 |
commit | fd9367ff35d3ef67f52f8612ba6df3c487b90f4d (patch) | |
tree | 68c676723f5f9cd1d66be903cfdce6b37dcc3719 /lib/libc/tests/stdio/fmemopen2_test.c | |
parent | 3d588fbc9bc229fdd93d6aaf6340583c2bcaca9f (diff) | |
parent | b708fe19431dfeacfe97dbc276190934bd53b483 (diff) | |
download | FreeBSD-src-fd9367ff35d3ef67f52f8612ba6df3c487b90f4d.zip FreeBSD-src-fd9367ff35d3ef67f52f8612ba6df3c487b90f4d.tar.gz |
MFhead @ r290899
Diffstat (limited to 'lib/libc/tests/stdio/fmemopen2_test.c')
-rw-r--r-- | lib/libc/tests/stdio/fmemopen2_test.c | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/lib/libc/tests/stdio/fmemopen2_test.c b/lib/libc/tests/stdio/fmemopen2_test.c index 9555173..c3aa6c5 100644 --- a/lib/libc/tests/stdio/fmemopen2_test.c +++ b/lib/libc/tests/stdio/fmemopen2_test.c @@ -35,15 +35,13 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <string.h> #include <strings.h> + #include <atf-c.h> ATF_TC_WITHOUT_HEAD(test_preexisting); ATF_TC_BODY(test_preexisting, tc) { - /* - * Use a pre-existing buffer. - */ - + /* Use a pre-existing buffer. */ char buf[512]; char buf2[512]; char str[] = "Test writing some stuff"; @@ -74,7 +72,7 @@ ATF_TC_BODY(test_preexisting, tc) nofr = fread(buf2, 1, sizeof(buf2), fp); ATF_REQUIRE(nofr == sizeof(buf2)); - /* + /* * Since a write on a FILE * retrieved by fmemopen * will add a '\0' (if there's space), we can check * the strings for equality. @@ -106,14 +104,10 @@ ATF_TC_BODY(test_preexisting, tc) ATF_TC_WITHOUT_HEAD(test_autoalloc); ATF_TC_BODY(test_autoalloc, tc) { - /* - * Let fmemopen allocate the buffer. - */ - - char str[] = "A quick test"; + /* Let fmemopen allocate the buffer. */ FILE *fp; long pos; - size_t nofw, nofr, i; + size_t nofw, i; int rc; /* Open a FILE * using fmemopen. */ @@ -130,9 +124,7 @@ ATF_TC_BODY(test_autoalloc, tc) pos = ftell(fp); ATF_REQUIRE(pos == 512); - /* - * Try to write past the end, we should get a short object count (0) - */ + /* Try to write past the end, we should get a short object count (0) */ nofw = fwrite("a", 1, 1, fp); ATF_REQUIRE(nofw == 0); @@ -173,10 +165,7 @@ ATF_TC_BODY(test_data_length, tc) nofw = fwrite(str, 1, sizeof(str), fp); ATF_REQUIRE(nofw == sizeof(str)); - /* - * Now seek to the end and check that ftell - * gives us sizeof(str). - */ + /* Now seek to the end and check that ftell gives us sizeof(str). */ rc = fseek(fp, 0, SEEK_END); ATF_REQUIRE(rc == 0); pos = ftell(fp); @@ -264,9 +253,7 @@ ATF_TC_BODY(test_append_binary_pos, tc) ATF_REQUIRE(ftell(fp) == 0L); fclose(fp); - /* - * Make sure that a pre-allocated buffer behaves correctly. - */ + /* Make sure that a pre-allocated buffer behaves correctly. */ char buf[] = "Hello"; fp = fmemopen(buf, sizeof(buf), "ab+"); ATF_REQUIRE(ftell(fp) == strlen(buf)); @@ -276,9 +263,7 @@ ATF_TC_BODY(test_append_binary_pos, tc) ATF_TC_WITHOUT_HEAD(test_size_0); ATF_TC_BODY(test_size_0, tc) { - /* - * POSIX mandates that we return EINVAL if size is 0. - */ + /* POSIX mandates that we return EINVAL if size is 0. */ FILE *fp; |