Lines Matching refs:fp
66 FILE* fp; in SetFileTo() local
67 ASSERT_NE(nullptr, fp = fopen(path, "w")); in SetFileTo()
68 ASSERT_NE(EOF, fputs(content, fp)); in SetFileTo()
69 ASSERT_EQ(0, fclose(fp)); in SetFileTo()
73 FILE* fp; in AssertFileIs() local
74 ASSERT_NE(nullptr, fp = fopen(path, "r")); in AssertFileIs()
77 ASSERT_NE(EOF, getline(&line, &length, fp)); in AssertFileIs()
78 ASSERT_EQ(0, fclose(fp)); in AssertFileIs()
83 static void AssertFileIs(FILE* fp, const char* expected, bool is_fmemopen = false) { in AssertFileIs() argument
84 rewind(fp); in AssertFileIs()
88 ASSERT_EQ(line, fgets(line, sizeof(line), fp)); in AssertFileIs()
94 ASSERT_EQ(line, fgets(line, sizeof(line), fp)); in AssertFileIs()
99 ASSERT_EQ(nullptr, fgets(line, sizeof(line), fp)) << "junk at end of file: " << line; in AssertFileIs()
111 FILE* fp = fopen("/dev/null", "w"); in TEST() local
112 ASSERT_TRUE(fp != nullptr); in TEST()
113 flockfile(fp); in TEST()
114 feof(fp); in TEST()
115 funlockfile(fp); in TEST()
116 fclose(fp); in TEST()
120 FILE* fp = tmpfile(); in TEST() local
121 ASSERT_TRUE(fp != nullptr); in TEST()
123 int fd = fileno(fp); in TEST()
131 rc = fprintf(fp, "hello\n"); in TEST()
134 AssertFileIs(fp, "hello\n"); in TEST()
135 fclose(fp); in TEST()
139 FILE* fp = tmpfile64(); in TEST() local
140 ASSERT_TRUE(fp != nullptr); in TEST()
141 fclose(fp); in TEST()
148 FILE* fp = tmpfile(); in TEST() local
149 ASSERT_TRUE(fp != nullptr); in TEST()
151 std::string fd_path = android::base::StringPrintf("/proc/self/fd/%d", fileno(fp)); in TEST()
175 FILE* fp = tmpfile(); in TEST() local
176 ASSERT_TRUE(fp != nullptr); in TEST()
179 int rc = fprintf(fp, "%s", line_written); in TEST()
182 rewind(fp); in TEST()
189 ASSERT_FALSE(feof(fp)); in TEST()
190 …ASSERT_EQ(getdelim(&word_read, &allocated_length, ' ', fp), static_cast<int>(strlen(expected[i]))); in TEST()
195 ASSERT_TRUE(feof(fp)); in TEST()
196 clearerr(fp); in TEST()
201 ASSERT_EQ(getdelim(&word_read, &allocated_length, ' ', fp), -1); in TEST()
203 ASSERT_TRUE(feof(fp)); in TEST()
206 fclose(fp); in TEST()
212 FILE* fp = tmpfile(); in TEST() local
213 ASSERT_TRUE(fp != nullptr); in TEST()
220 ASSERT_EQ(getdelim(nullptr, &buffer_length, ' ', fp), -1); in TEST()
225 ASSERT_EQ(getdelim(&buffer, nullptr, ' ', fp), -1); in TEST()
227 fclose(fp); in TEST()
232 FILE* fp = fopen("/proc", "r"); in TEST() local
233 ASSERT_TRUE(fp != nullptr); in TEST()
236 ASSERT_EQ(-1, getdelim(&word_read, &allocated_length, ' ', fp)); in TEST()
237 fclose(fp); in TEST()
241 FILE* fp = tmpfile(); in TEST() local
242 ASSERT_TRUE(fp != nullptr); in TEST()
248 int rc = fprintf(fp, "%s", line_written); in TEST()
252 rewind(fp); in TEST()
259 while ((read_char_count = getline(&line_read, &allocated_length, fp)) != -1) { in TEST()
268 ASSERT_TRUE(feof(fp)); in TEST()
269 clearerr(fp); in TEST()
274 ASSERT_EQ(getline(&line_read, &allocated_length, fp), -1); in TEST()
276 ASSERT_TRUE(feof(fp)); in TEST()
279 fclose(fp); in TEST()
285 FILE* fp = tmpfile(); in TEST() local
286 ASSERT_TRUE(fp != nullptr); in TEST()
293 ASSERT_EQ(getline(nullptr, &buffer_length, fp), -1); in TEST()
298 ASSERT_EQ(getline(&buffer, nullptr, fp), -1); in TEST()
300 fclose(fp); in TEST()
945 FILE* fp; in TEST() local
950 ASSERT_NE(nullptr, fp = tmpfile()); in TEST()
951 setbuf(fp, nullptr); in TEST()
952 ASSERT_EQ(4, fprintf(fp, "epic")); in TEST()
953 ASSERT_NE(-1, dup2(fd_rdonly, fileno(fp))); in TEST()
954 ASSERT_EQ(-1, fprintf(fp, "fail")); in TEST()
955 ASSERT_EQ(0, fclose(fp)); in TEST()
961 ASSERT_NE(nullptr, fp = tmpfile()); in TEST()
962 ASSERT_EQ(4, fprintf(fp, "epic")); in TEST()
963 ASSERT_NE(-1, dup2(fd_rdonly, fileno(fp))); in TEST()
964 ASSERT_EQ(4, fprintf(fp, "fail")); in TEST()
965 ASSERT_EQ(-1, fclose(fp)); in TEST()
969 FILE* fp = popen("cat /proc/version", "r"); in TEST() local
970 ASSERT_TRUE(fp != nullptr); in TEST()
973 char* s = fgets(buf, sizeof(buf), fp); in TEST()
977 ASSERT_EQ(0, pclose(fp)); in TEST()
981 FILE* fp = popen("cat", "r+"); in TEST() local
982 ASSERT_TRUE(fp != nullptr); in TEST()
984 fputs("hello\nworld\n", fp); in TEST()
985 fflush(fp); in TEST()
988 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
990 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
993 ASSERT_EQ(0, pclose(fp)); in TEST()
997 FILE* fp = popen("uniq -c", "r+"); in TEST() local
998 ASSERT_TRUE(fp != nullptr); in TEST()
1000 fputs("a\na\na\na\nb\n", fp); in TEST()
1001 fflush(fp); in TEST()
1002 ASSERT_EQ(0, shutdown(fileno(fp), SHUT_WR)); in TEST()
1005 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
1007 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
1010 ASSERT_EQ(0, pclose(fp)); in TEST()
1014 FILE* fp = popen("true", "r"); in TEST() local
1015 ASSERT_TRUE(fp != nullptr); in TEST()
1016 int status = pclose(fp); in TEST()
1022 FILE* fp = popen("false", "r"); in TEST() local
1023 ASSERT_TRUE(fp != nullptr); in TEST()
1024 int status = pclose(fp); in TEST()
1030 FILE* fp = popen("kill -7 $$", "r"); in TEST() local
1031 ASSERT_TRUE(fp != nullptr); in TEST()
1032 int status = pclose(fp); in TEST()
1038 FILE* fp = fopen("/proc/version", "r"); in TEST() local
1039 ASSERT_TRUE(fp != nullptr); in TEST()
1040 ASSERT_EQ('L', getc(fp)); in TEST()
1041 ASSERT_EQ('i', getc(fp)); in TEST()
1042 ASSERT_EQ('n', getc(fp)); in TEST()
1043 ASSERT_EQ('u', getc(fp)); in TEST()
1044 ASSERT_EQ('x', getc(fp)); in TEST()
1045 fclose(fp); in TEST()
1049 FILE* fp = fopen("/proc/version", "r"); in TEST() local
1050 ASSERT_TRUE(fp != nullptr); in TEST()
1051 ASSERT_EQ(EOF, putc('x', fp)); in TEST()
1052 fclose(fp); in TEST()
1372 FILE* fp = fopen("/proc/version", "r"); in TEST() local
1380 EXPECT_EQ(EOF, putc('x', fp)); in TEST()
1384 EXPECT_EQ(EOF, fprintf(fp, "hello")); in TEST()
1388 EXPECT_EQ(EOF, fwprintf(fp, L"hello")); in TEST()
1394 EXPECT_EQ(0U, fwrite("hello", 1, 2, fp)); in TEST()
1398 EXPECT_EQ(EOF, fputs("hello", fp)); in TEST()
1402 EXPECT_EQ(WEOF, fputwc(L'x', fp)); in TEST()
1414 FILE* fp = tmpfile(); in TEST() local
1415 ASSERT_TRUE(fp != nullptr); in TEST()
1423 ASSERT_EQ(mb_one_bytes, static_cast<wchar_t>(fputwc(mb_one_bytes, fp))); in TEST()
1424 ASSERT_EQ(mb_two_bytes, static_cast<wchar_t>(fputwc(mb_two_bytes, fp))); in TEST()
1425 ASSERT_EQ(mb_three_bytes, static_cast<wchar_t>(fputwc(mb_three_bytes, fp))); in TEST()
1426 ASSERT_EQ(mb_four_bytes, static_cast<wchar_t>(fputwc(mb_four_bytes, fp))); in TEST()
1428 rewind(fp); in TEST()
1436 EXPECT_EQ(0, fgetpos(fp, &pos1)); in TEST()
1437 ASSERT_EQ(mb_one_bytes, static_cast<wchar_t>(fgetwc(fp))); in TEST()
1438 EXPECT_EQ(0, fgetpos(fp, &pos2)); in TEST()
1439 ASSERT_EQ(mb_two_bytes, static_cast<wchar_t>(fgetwc(fp))); in TEST()
1440 EXPECT_EQ(0, fgetpos(fp, &pos3)); in TEST()
1441 ASSERT_EQ(mb_three_bytes, static_cast<wchar_t>(fgetwc(fp))); in TEST()
1442 EXPECT_EQ(0, fgetpos(fp, &pos4)); in TEST()
1443 ASSERT_EQ(mb_four_bytes, static_cast<wchar_t>(fgetwc(fp))); in TEST()
1444 EXPECT_EQ(0, fgetpos(fp, &pos5)); in TEST()
1459 ASSERT_EQ(0, fsetpos(fp, &pos2)); in TEST()
1460 ASSERT_EQ(mb_two_bytes, static_cast<wchar_t>(fgetwc(fp))); in TEST()
1461 ASSERT_EQ(0, fsetpos(fp, &pos1)); in TEST()
1462 ASSERT_EQ(mb_one_bytes, static_cast<wchar_t>(fgetwc(fp))); in TEST()
1463 ASSERT_EQ(0, fsetpos(fp, &pos4)); in TEST()
1464 ASSERT_EQ(mb_four_bytes, static_cast<wchar_t>(fgetwc(fp))); in TEST()
1465 ASSERT_EQ(0, fsetpos(fp, &pos3)); in TEST()
1466 ASSERT_EQ(mb_three_bytes, static_cast<wchar_t>(fgetwc(fp))); in TEST()
1467 ASSERT_EQ(0, fsetpos(fp, &pos5)); in TEST()
1468 ASSERT_EQ(WEOF, fgetwc(fp)); in TEST()
1470 fclose(fp); in TEST()
1484 FILE* fp = fdopen(tf.fd, "w+"); in TEST() local
1485 ASSERT_TRUE(fp != nullptr); in TEST()
1492 ASSERT_EQ(mb_two_bytes, static_cast<wchar_t>(fputwc(mb_two_bytes, fp))); in TEST()
1493 ASSERT_EQ(mb_three_bytes, static_cast<wchar_t>(fputwc(mb_three_bytes, fp))); in TEST()
1494 ASSERT_EQ(mb_four_bytes, static_cast<wchar_t>(fputwc(mb_four_bytes, fp))); in TEST()
1496 fflush(fp); in TEST()
1497 fclose(fp); in TEST()
1499 fp = fopen(tf.path, "r"); in TEST()
1500 ASSERT_TRUE(fp != nullptr); in TEST()
1504 ASSERT_EQ(0, fgetpos(fp, &mb_two_bytes_pos)); in TEST()
1508 ASSERT_EQ(0, fseek(fp, offset_inside_mb, SEEK_SET)); in TEST()
1512 ASSERT_EQ(0, fgetpos(fp, &pos_inside_mb)); in TEST()
1518 ASSERT_EQ(WEOF, fgetwc(fp)); in TEST()
1522 ASSERT_EQ(0, fsetpos(fp, &mb_two_bytes_pos)); in TEST()
1523 ASSERT_EQ(mb_two_bytes, static_cast<wchar_t>(fgetwc(fp))); in TEST()
1527 ASSERT_EQ(0, fsetpos(fp, &pos_inside_mb)); in TEST()
1528 ASSERT_EQ(WEOF, fgetwc(fp)); in TEST()
1531 ASSERT_EQ(0, fclose(fp)); in TEST()
1537 FILE* fp = fmemopen(buf, sizeof(buf), "r+"); in TEST() local
1538 ASSERT_EQ('<', fputc('<', fp)); in TEST()
1539 ASSERT_NE(EOF, fputs("abc>\n", fp)); in TEST()
1540 fflush(fp); in TEST()
1546 AssertFileIs(fp, "<abc>\n", true); in TEST()
1547 ASSERT_EQ(0, fclose(fp)); in TEST()
1551 FILE* fp = fmemopen(nullptr, 128, "r+"); in TEST() local
1552 ASSERT_NE(EOF, fputs("xyz\n", fp)); in TEST()
1554 AssertFileIs(fp, "xyz\n", true); in TEST()
1555 ASSERT_EQ(0, fclose(fp)); in TEST()
1559 FILE* fp; in TEST() local
1566 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w")); in TEST()
1568 ASSERT_EQ(0, fflush(fp)); in TEST()
1571 ASSERT_NE(EOF, fputs("hello", fp)); in TEST()
1572 ASSERT_EQ(0, fflush(fp)); in TEST()
1574 ASSERT_NE(EOF, fputs("wo", fp)); in TEST()
1575 ASSERT_EQ(0, fflush(fp)); in TEST()
1577 ASSERT_EQ(0, fclose(fp)); in TEST()
1583 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "r+")); in TEST()
1585 ASSERT_EQ(0, fflush(fp)); in TEST()
1587 ASSERT_NE(EOF, fputs("hello", fp)); in TEST()
1588 ASSERT_EQ(0, fclose(fp)); in TEST()
1592 FILE* fp; in TEST() local
1602 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "r")); in TEST()
1603 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1604 EXPECT_EQ(16, ftell(fp)); in TEST()
1605 EXPECT_EQ(16, ftello(fp)); in TEST()
1606 ASSERT_EQ(0, fseeko(fp, 0, SEEK_END)); in TEST()
1607 EXPECT_EQ(16, ftell(fp)); in TEST()
1608 EXPECT_EQ(16, ftello(fp)); in TEST()
1609 ASSERT_EQ(0, fclose(fp)); in TEST()
1610 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "r+")); in TEST()
1611 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1612 EXPECT_EQ(16, ftell(fp)); in TEST()
1613 EXPECT_EQ(16, ftello(fp)); in TEST()
1614 ASSERT_EQ(0, fseeko(fp, 0, SEEK_END)); in TEST()
1615 EXPECT_EQ(16, ftell(fp)); in TEST()
1616 EXPECT_EQ(16, ftello(fp)); in TEST()
1617 ASSERT_EQ(0, fclose(fp)); in TEST()
1620 ASSERT_NE(nullptr, fp = fmemopen(nullptr, 16, "w")); in TEST()
1621 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1622 EXPECT_EQ(0, ftell(fp)); in TEST()
1623 EXPECT_EQ(0, ftello(fp)); in TEST()
1624 ASSERT_EQ(0, fseeko(fp, 0, SEEK_END)); in TEST()
1625 EXPECT_EQ(0, ftell(fp)); in TEST()
1626 EXPECT_EQ(0, ftello(fp)); in TEST()
1627 ASSERT_EQ(0, fclose(fp)); in TEST()
1628 ASSERT_NE(nullptr, fp = fmemopen(nullptr, 16, "w+")); in TEST()
1629 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1630 EXPECT_EQ(0, ftell(fp)); in TEST()
1631 EXPECT_EQ(0, ftello(fp)); in TEST()
1632 ASSERT_EQ(0, fseeko(fp, 0, SEEK_END)); in TEST()
1633 EXPECT_EQ(0, ftell(fp)); in TEST()
1634 EXPECT_EQ(0, ftello(fp)); in TEST()
1635 ASSERT_EQ(0, fclose(fp)); in TEST()
1639 ASSERT_NE(nullptr, fp = fmemopen(nullptr, 16, "a")); in TEST()
1640 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1641 EXPECT_EQ(0, ftell(fp)); in TEST()
1642 EXPECT_EQ(0, ftello(fp)); in TEST()
1643 ASSERT_EQ(0, fseeko(fp, 0, SEEK_END)); in TEST()
1644 EXPECT_EQ(0, ftell(fp)); in TEST()
1645 EXPECT_EQ(0, ftello(fp)); in TEST()
1646 ASSERT_EQ(0, fclose(fp)); in TEST()
1647 ASSERT_NE(nullptr, fp = fmemopen(nullptr, 16, "a+")); in TEST()
1648 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1649 EXPECT_EQ(0, ftell(fp)); in TEST()
1650 EXPECT_EQ(0, ftello(fp)); in TEST()
1651 ASSERT_EQ(0, fseeko(fp, 0, SEEK_END)); in TEST()
1652 EXPECT_EQ(0, ftell(fp)); in TEST()
1653 EXPECT_EQ(0, ftello(fp)); in TEST()
1654 ASSERT_EQ(0, fclose(fp)); in TEST()
1659 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a")); in TEST()
1660 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1661 EXPECT_EQ(3, ftell(fp)); in TEST()
1662 EXPECT_EQ(3, ftello(fp)); in TEST()
1663 ASSERT_EQ(0, fseeko(fp, 0, SEEK_END)); in TEST()
1664 EXPECT_EQ(3, ftell(fp)); in TEST()
1665 EXPECT_EQ(3, ftello(fp)); in TEST()
1666 ASSERT_EQ(0, fclose(fp)); in TEST()
1669 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a+")); in TEST()
1670 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1671 EXPECT_EQ(3, ftell(fp)); in TEST()
1672 EXPECT_EQ(3, ftello(fp)); in TEST()
1673 ASSERT_EQ(0, fseeko(fp, 0, SEEK_END)); in TEST()
1674 EXPECT_EQ(3, ftell(fp)); in TEST()
1675 EXPECT_EQ(3, ftello(fp)); in TEST()
1676 ASSERT_EQ(0, fclose(fp)); in TEST()
1681 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a")); in TEST()
1682 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1683 EXPECT_EQ(16, ftell(fp)); in TEST()
1684 EXPECT_EQ(16, ftello(fp)); in TEST()
1685 ASSERT_EQ(0, fseeko(fp, 0, SEEK_END)); in TEST()
1686 EXPECT_EQ(16, ftell(fp)); in TEST()
1687 EXPECT_EQ(16, ftello(fp)); in TEST()
1688 ASSERT_EQ(0, fclose(fp)); in TEST()
1690 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a+")); in TEST()
1691 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1692 EXPECT_EQ(16, ftell(fp)); in TEST()
1693 EXPECT_EQ(16, ftello(fp)); in TEST()
1694 ASSERT_EQ(0, fseeko(fp, 0, SEEK_END)); in TEST()
1695 EXPECT_EQ(16, ftell(fp)); in TEST()
1696 EXPECT_EQ(16, ftello(fp)); in TEST()
1697 ASSERT_EQ(0, fclose(fp)); in TEST()
1702 FILE* fp; in TEST() local
1706 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w+")); in TEST()
1707 ASSERT_NE(EOF, fputs("string", fp)); in TEST()
1708 EXPECT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1709 EXPECT_EQ(static_cast<long>(strlen("string")), ftell(fp)); in TEST()
1710 EXPECT_EQ(static_cast<off_t>(strlen("string")), ftello(fp)); in TEST()
1711 EXPECT_EQ(0, fclose(fp)); in TEST()
1715 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w+")); in TEST()
1716 ASSERT_NE(EOF, fputs("54321", fp)); in TEST()
1717 EXPECT_EQ(0, fseek(fp, -2, SEEK_END)); in TEST()
1718 EXPECT_EQ('2', fgetc(fp)); in TEST()
1719 EXPECT_EQ(0, fclose(fp)); in TEST()
1725 FILE* fp = fmemopen(buf, sizeof(buf), "w"); in TEST() local
1726 ASSERT_TRUE(fp != nullptr); in TEST()
1732 EXPECT_EQ(-1, fseek(fp, -2, SEEK_SET)); in TEST()
1733 EXPECT_EQ(-1, fseeko(fp, -2, SEEK_SET)); in TEST()
1734 EXPECT_EQ(-1, fseek(fp, sizeof(buf) + 1, SEEK_SET)); in TEST()
1735 EXPECT_EQ(-1, fseeko(fp, sizeof(buf) + 1, SEEK_SET)); in TEST()
1743 FILE* fp = fmemopen(buf, sizeof(buf), "r"); in TEST() local
1744 ASSERT_TRUE(fp != nullptr); in TEST()
1746 ASSERT_EQ(8U, fread(buf2, 1, sizeof(buf2), fp)); in TEST()
1749 ASSERT_TRUE(feof(fp)); in TEST()
1750 ASSERT_EQ(EOF, fgetc(fp)); in TEST()
1751 ASSERT_EQ(0, fclose(fp)); in TEST()
1757 FILE* fp = fmemopen(buf, sizeof(buf), "r"); in TEST() local
1758 ASSERT_TRUE(fp != nullptr); in TEST()
1759 ASSERT_EQ('h', fgetc(fp)); in TEST()
1760 ASSERT_EQ(0, fgetc(fp)); in TEST()
1761 ASSERT_EQ('e', fgetc(fp)); in TEST()
1762 ASSERT_EQ(0, fgetc(fp)); in TEST()
1763 ASSERT_EQ('l', fgetc(fp)); in TEST()
1764 ASSERT_EQ(0, fgetc(fp)); in TEST()
1769 ASSERT_EQ(4U, fread(buf2, 1, sizeof(buf2), fp)); in TEST()
1775 ASSERT_TRUE(feof(fp)); in TEST()
1776 ASSERT_EQ(0, fclose(fp)); in TEST()
1780 FILE* fp; in TEST() local
1786 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "r+")); in TEST()
1787 setbuf(fp, nullptr); // Turn off buffering so we can see what's happening as it happens. in TEST()
1788 ASSERT_EQ(0, fseek(fp, 2, SEEK_SET)); in TEST()
1789 ASSERT_EQ(' ', fputc(' ', fp)); in TEST()
1791 ASSERT_EQ(0, fclose(fp)); in TEST()
1798 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a+")); in TEST()
1799 setbuf(fp, nullptr); // Turn off buffering so we can see what's happening as it happens. in TEST()
1800 ASSERT_EQ(' ', fputc(' ', fp)); in TEST()
1802 ASSERT_EQ(0, fclose(fp)); in TEST()
1809 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w+")); in TEST()
1810 setbuf(fp, nullptr); // Turn off buffering so we can see what's happening as it happens. in TEST()
1811 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1812 EXPECT_EQ(0, ftell(fp)); in TEST()
1813 ASSERT_EQ(' ', fputc(' ', fp)); in TEST()
1814 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1815 EXPECT_EQ(1, ftell(fp)); in TEST()
1816 ASSERT_NE(EOF, fputs("123", fp)); in TEST()
1817 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
1818 EXPECT_EQ(4, ftell(fp)); in TEST()
1820 ASSERT_EQ(0, fclose(fp)); in TEST()
1826 FILE* fp; in TEST() local
1829 ASSERT_NE(nullptr, fp = fmemopen(nullptr, 4, "w")); in TEST()
1830 setbuf(fp, nullptr); // Turn off buffering so we can see what's happening as it happens. in TEST()
1831 ASSERT_EQ('x', fputc('x', fp)); in TEST()
1832 ASSERT_EQ('x', fputc('x', fp)); in TEST()
1833 ASSERT_EQ('x', fputc('x', fp)); in TEST()
1834 ASSERT_EQ(EOF, fputc('x', fp)); // Only 3 fit because of the implicit NUL. in TEST()
1835 ASSERT_EQ(0, fclose(fp)); in TEST()
1838 ASSERT_NE(nullptr, fp = fmemopen(nullptr, 4, "w")); in TEST()
1839 setbuf(fp, nullptr); // Turn off buffering so we can see what's happening as it happens. in TEST()
1840 ASSERT_EQ(3U, fwrite("xxxx", 1, 4, fp)); in TEST()
1841 ASSERT_EQ(0, fclose(fp)); in TEST()
1848 FILE* fp; in TEST() local
1849 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "r")); in TEST()
1850 EXPECT_EQ(0L, ftell(fp)); in TEST()
1851 EXPECT_EQ(0, fclose(fp)); in TEST()
1852 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w")); in TEST()
1853 EXPECT_EQ(0L, ftell(fp)); in TEST()
1854 EXPECT_EQ(0, fclose(fp)); in TEST()
1858 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a")); in TEST()
1859 EXPECT_EQ(5L, ftell(fp)); in TEST()
1860 EXPECT_EQ(0, fclose(fp)); in TEST()
1865 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a")); in TEST()
1866 EXPECT_EQ(static_cast<long>(sizeof(buf)), ftell(fp)); in TEST()
1867 EXPECT_EQ(0, fclose(fp)); in TEST()
1873 FILE* fp = fmemopen(nullptr, 128, "a+"); in TEST() local
1874 ASSERT_TRUE(fp != nullptr); in TEST()
1875 EXPECT_EQ(0L, ftell(fp)); in TEST()
1876 EXPECT_EQ(0L, fseek(fp, 0, SEEK_SET)); in TEST()
1877 EXPECT_EQ(0, fclose(fp)); in TEST()
1885 FILE* fp; in TEST() local
1887 ASSERT_NE(nullptr, fp = fmemopen(buf, 0, "r+")); in TEST()
1888 ASSERT_EQ(EOF, fgetc(fp)); in TEST()
1889 ASSERT_TRUE(feof(fp)); in TEST()
1890 ASSERT_EQ(0, fclose(fp)); in TEST()
1891 ASSERT_NE(nullptr, fp = fmemopen(nullptr, 0, "r+")); in TEST()
1892 ASSERT_EQ(EOF, fgetc(fp)); in TEST()
1893 ASSERT_TRUE(feof(fp)); in TEST()
1894 ASSERT_EQ(0, fclose(fp)); in TEST()
1896 ASSERT_NE(nullptr, fp = fmemopen(buf, 0, "w+")); in TEST()
1897 setbuf(fp, nullptr); // Turn off buffering so we can see what's happening as it happens. in TEST()
1898 ASSERT_EQ(EOF, fputc('x', fp)); in TEST()
1899 ASSERT_EQ(0, fclose(fp)); in TEST()
1900 ASSERT_NE(nullptr, fp = fmemopen(nullptr, 0, "w+")); in TEST()
1901 setbuf(fp, nullptr); // Turn off buffering so we can see what's happening as it happens. in TEST()
1902 ASSERT_EQ(EOF, fputc('x', fp)); in TEST()
1903 ASSERT_EQ(0, fclose(fp)); in TEST()
1909 FILE* fp = fmemopen(buf, 0, "w"); in TEST() local
1911 ASSERT_EQ(0, fclose(fp)); in TEST()
1917 FILE* fp; in TEST() local
1918 ASSERT_NE(nullptr, fp = fmemopen(nullptr, 16, "r")); in TEST()
1919 ASSERT_EQ(0, fclose(fp)); in TEST()
1920 ASSERT_NE(nullptr, fp = fmemopen(nullptr, 16, "w")); in TEST()
1921 ASSERT_EQ(0, fclose(fp)); in TEST()
1926 FILE* fp = fmemopen(nullptr, 16, "r"); in TEST() local
1927 ASSERT_TRUE(fp != nullptr); in TEST()
1929 ASSERT_EQ(-1, fileno(fp)); in TEST()
1931 ASSERT_EQ(0, fclose(fp)); in TEST()
1938 FILE* fp; in TEST() local
1940 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a")); in TEST()
1941 setbuf(fp, nullptr); // Turn off buffering so we can see what's happening as it happens. in TEST()
1942 ASSERT_EQ(0, fseek(fp, 0, SEEK_SET)); in TEST()
1943 ASSERT_NE(EOF, fputc('!', fp)); in TEST()
1945 ASSERT_EQ(0, fclose(fp)); in TEST()
1948 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a+")); in TEST()
1949 setbuf(fp, nullptr); // Turn off buffering so we can see what's happening as it happens. in TEST()
1950 ASSERT_EQ(0, fseek(fp, 0, SEEK_SET)); in TEST()
1951 ASSERT_NE(EOF, fputc('!', fp)); in TEST()
1953 ASSERT_EQ(0, fclose(fp)); in TEST()
1959 FILE* fp = open_memstream(&p, &size); in TEST() local
1960 ASSERT_NE(EOF, fputs("hello, world!", fp)); in TEST()
1961 fclose(fp); in TEST()
1995 FILE* fp = fdopen(fd, "re"); in TEST() local
1996 ASSERT_TRUE(CloseOnExec(fileno(fp))); in TEST()
1997 fclose(fp); in TEST()
2005 FILE* fp = fdopen(fd, "r"); in TEST() local
2006 ASSERT_TRUE(CloseOnExec(fileno(fp))); in TEST()
2007 fclose(fp); in TEST()
2012 FILE* fp = fopen("/proc/version", "r"); in TEST() local
2013 ASSERT_FALSE(CloseOnExec(fileno(fp))); in TEST()
2015 fp = freopen("/proc/version", "re", fp); in TEST()
2016 ASSERT_TRUE(CloseOnExec(fileno(fp))); in TEST()
2018 fclose(fp); in TEST()
2023 FILE* fp = fopen("/proc/version", "re"); in TEST() local
2024 ASSERT_TRUE(CloseOnExec(fileno(fp))); in TEST()
2026 fp = freopen("/proc/version", "r", fp); in TEST()
2027 ASSERT_FALSE(CloseOnExec(fileno(fp))); in TEST()
2028 fclose(fp); in TEST()
2033 FILE* fp = fopen("/proc/version", "r"); in TEST() local
2034 ASSERT_FALSE(CloseOnExec(fileno(fp))); in TEST()
2036 fp = freopen(nullptr, "re", fp); in TEST()
2037 ASSERT_TRUE(CloseOnExec(fileno(fp))); in TEST()
2038 fclose(fp); in TEST()
2043 FILE* fp = fopen("/proc/version", "re"); in TEST() local
2044 ASSERT_TRUE(CloseOnExec(fileno(fp))); in TEST()
2046 fp = freopen(nullptr, "r", fp); in TEST()
2047 ASSERT_FALSE(CloseOnExec(fileno(fp))); in TEST()
2048 fclose(fp); in TEST()
2052 FILE* fp = fopen64("/proc/version", "r"); in TEST() local
2053 ASSERT_TRUE(fp != nullptr); in TEST()
2054 fp = freopen64("/proc/version", "re", fp); in TEST()
2055 ASSERT_TRUE(fp != nullptr); in TEST()
2056 fclose(fp); in TEST()
2062 FILE* fp = fopen("/dev/zero", "r"); in TEST() local
2063 ASSERT_TRUE(fp != nullptr); in TEST()
2066 setvbuf(fp, nullptr, _IONBF, 0); in TEST()
2073 ASSERT_EQ(1U, fread(buf, 64*1024, 1, fp)); in TEST()
2077 fclose(fp); in TEST()
2092 FILE* fp = fmemopen(&digits[0], digits.size(), "r"); in TEST() local
2097 ASSERT_EQ(2U, fread(buf1, 4, 4, fp)); in TEST()
2099 ASSERT_TRUE(feof(fp)); in TEST()
2101 rewind(fp); in TEST()
2106 ASSERT_EQ(2U, fread(buf2, 4, 4096, fp)); in TEST()
2108 ASSERT_TRUE(feof(fp)); in TEST()
2110 fclose(fp); in TEST()
2114 FILE* fp = fopen("/dev/null", "w"); in test_fread_from_write_only_stream() local
2117 ASSERT_EQ(0U, fread(&buf[0], n, 1, fp)); in test_fread_from_write_only_stream()
2119 ASSERT_TRUE(ferror(fp)); in test_fread_from_write_only_stream()
2120 ASSERT_FALSE(feof(fp)); in test_fread_from_write_only_stream()
2121 fclose(fp); in test_fread_from_write_only_stream()
2135 FILE* fp = fdopen(tf.fd, "w+"); in test_fwrite_after_fread() local
2136 ASSERT_EQ(1U, fwrite("1", 1, 1, fp)); in test_fwrite_after_fread()
2137 fflush(fp); in test_fwrite_after_fread()
2141 ASSERT_EQ(0U, fread(&buf[0], 1, buf.size(), fp)); in test_fwrite_after_fread()
2142 ASSERT_TRUE(feof(fp)); in test_fwrite_after_fread()
2146 ASSERT_EQ(1U, fwrite("2", 1, 1, fp)) << strerror(errno); in test_fwrite_after_fread()
2149 rewind(fp); in test_fwrite_after_fread()
2150 ASSERT_EQ(2U, fread(&buf[0], 1, buf.size(), fp)); in test_fwrite_after_fread()
2154 fclose(fp); in test_fwrite_after_fread()
2169 FILE* fp = fopen(tf.path, "w+"); in TEST() local
2170 ASSERT_TRUE(fp != nullptr); in TEST()
2176 ASSERT_EQ(12288U, fwrite(file_data, 1, 12288, fp)); in TEST()
2177 fclose(fp); in TEST()
2179 fp = fopen(tf.path, "r"); in TEST()
2180 ASSERT_TRUE(fp != nullptr); in TEST()
2185 ASSERT_EQ(100U, fread(buffer, 1, 100, fp)); in TEST()
2188 cur_location = static_cast<size_t>(ftell(fp)); in TEST()
2191 ASSERT_EQ(8192U, fread(buffer, 1, 8192, fp)); in TEST()
2195 ASSERT_EQ(0, fseek(fp, -22, SEEK_CUR)) << strerror(errno); in TEST()
2196 cur_location = static_cast<size_t>(ftell(fp)); in TEST()
2197 ASSERT_EQ(22U, fread(buffer, 1, 22, fp)); in TEST()
2200 fclose(fp); in TEST()
2256 FILE* fp = funopen(nullptr, read_fn, nullptr, nullptr, nullptr); in TEST() local
2257 ASSERT_TRUE(fp != nullptr); in TEST()
2261 ASSERT_EQ(-1, ftell(fp)); in TEST()
2266 ASSERT_EQ(-1, fseek(fp, 0, SEEK_CUR)); in TEST()
2271 ASSERT_EQ(-1, fseek(fp, 0, SEEK_SET)); in TEST()
2274 fclose(fp); in TEST()
2297 FILE* fp = funopen(nullptr, read_fn, nullptr, seek_fn, nullptr); in TEST() local
2298 ASSERT_TRUE(fp != nullptr); in TEST()
2301 EXPECT_EQ(0, fgetpos(fp, &pos)) << strerror(errno); in TEST()
2304 EXPECT_EQ(-1, fgetpos(fp, &pos)) << strerror(errno); in TEST()
2325 FILE* fp = fopen(tf->path, "w+"); in TEST() local
2326 fps.push_back(fp); in TEST()
2327 fprintf(fp, "hello %zu!\n", i); in TEST()
2328 fflush(fp); in TEST()
2341 static void AssertFileOffsetAt(FILE* fp, off64_t offset) { in AssertFileOffsetAt() argument
2342 EXPECT_EQ(offset, ftell(fp)); in AssertFileOffsetAt()
2343 EXPECT_EQ(offset, ftello(fp)); in AssertFileOffsetAt()
2344 EXPECT_EQ(offset, ftello64(fp)); in AssertFileOffsetAt()
2347 EXPECT_EQ(0, fgetpos(fp, &pos)); in AssertFileOffsetAt()
2348 EXPECT_EQ(0, fgetpos64(fp, &pos64)); in AssertFileOffsetAt()
2359 FILE* fp = fdopen(tf.fd, "w+"); in TEST() local
2362 AssertFileOffsetAt(fp, 0); in TEST()
2365 ASSERT_EQ(0, fseek(fp, 8192, SEEK_SET)); in TEST()
2366 AssertFileOffsetAt(fp, 8192); in TEST()
2368 ASSERT_EQ(0, fgetpos(fp, &eight_k_pos)); in TEST()
2371 ASSERT_EQ(0, fseek(fp, 8192, SEEK_CUR)); in TEST()
2372 AssertFileOffsetAt(fp, 8192 + 8192); in TEST()
2374 ASSERT_EQ(0, fgetpos64(fp, &sixteen_k_pos64)); in TEST()
2377 ASSERT_EQ(0, fseek(fp, -8192, SEEK_CUR)); in TEST()
2378 AssertFileOffsetAt(fp, 8192); in TEST()
2381 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
2382 AssertFileOffsetAt(fp, 0); in TEST()
2385 ASSERT_EQ(0, fsetpos64(fp, &sixteen_k_pos64)); in TEST()
2386 AssertFileOffsetAt(fp, 8192 + 8192); in TEST()
2388 ASSERT_EQ(0, fsetpos(fp, &eight_k_pos)); in TEST()
2389 AssertFileOffsetAt(fp, 8192); in TEST()
2392 ASSERT_EQ(0, fseeko(fp, 1234, SEEK_SET)); in TEST()
2393 AssertFileOffsetAt(fp, 1234); in TEST()
2394 ASSERT_EQ(0, fseeko64(fp, 5678, SEEK_SET)); in TEST()
2395 AssertFileOffsetAt(fp, 5678); in TEST()
2397 fclose(fp); in TEST()
2402 FILE* fp = fdopen(tf.fd, "w+"); in TEST() local
2406 ASSERT_EQ(-1, fseek(fp, 0, 123)); in TEST()
2409 ASSERT_EQ(-1, fseeko(fp, 0, 123)); in TEST()
2412 ASSERT_EQ(-1, fseeko64(fp, 0, 123)); in TEST()
2417 ASSERT_EQ(-1, fseek(fp, -1, SEEK_SET)); in TEST()
2420 ASSERT_EQ(-1, fseeko(fp, -1, SEEK_SET)); in TEST()
2423 ASSERT_EQ(-1, fseeko64(fp, -1, SEEK_SET)); in TEST()
2426 fclose(fp); in TEST()
2533 FILE* fp = fopen(tf.path, "a"); in TEST() local
2534 EXPECT_EQ(10, ftell(fp)); in TEST()
2535 ASSERT_EQ(0, fseek(fp, 2, SEEK_SET)); in TEST()
2536 EXPECT_EQ(2, ftell(fp)); in TEST()
2537 ASSERT_NE(EOF, fputs("xxx", fp)); in TEST()
2538 ASSERT_EQ(0, fflush(fp)); in TEST()
2539 EXPECT_EQ(13, ftell(fp)); in TEST()
2540 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
2541 EXPECT_EQ(13, ftell(fp)); in TEST()
2542 ASSERT_EQ(0, fclose(fp)); in TEST()
2554 FILE* fp = fdopen(fd, "a"); in TEST() local
2555 EXPECT_EQ(4, ftell(fp)); in TEST()
2556 ASSERT_EQ(0, fseek(fp, 2, SEEK_SET)); in TEST()
2557 EXPECT_EQ(2, ftell(fp)); in TEST()
2558 ASSERT_NE(EOF, fputs("xxx", fp)); in TEST()
2559 ASSERT_EQ(0, fflush(fp)); in TEST()
2560 EXPECT_EQ(13, ftell(fp)); in TEST()
2561 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
2562 EXPECT_EQ(13, ftell(fp)); in TEST()
2563 ASSERT_EQ(0, fclose(fp)); in TEST()
2571 FILE* fp = freopen(tf.path, "a", other_fp); in TEST() local
2572 EXPECT_EQ(10, ftell(fp)); in TEST()
2573 ASSERT_EQ(0, fseek(fp, 2, SEEK_SET)); in TEST()
2574 EXPECT_EQ(2, ftell(fp)); in TEST()
2575 ASSERT_NE(EOF, fputs("xxx", fp)); in TEST()
2576 ASSERT_EQ(0, fflush(fp)); in TEST()
2577 EXPECT_EQ(13, ftell(fp)); in TEST()
2578 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
2579 EXPECT_EQ(13, ftell(fp)); in TEST()
2580 ASSERT_EQ(0, fclose(fp)); in TEST()
2614 FILE* fp = fopen(tf.path, "w+"); in TEST() local
2615 ASSERT_TRUE(fp != nullptr); in TEST()
2617 clearerr_unlocked(fp); in TEST()
2618 ASSERT_FALSE(feof_unlocked(fp)); in TEST()
2619 ASSERT_FALSE(ferror_unlocked(fp)); in TEST()
2621 ASSERT_EQ(fileno(fp), fileno_unlocked(fp)); in TEST()
2623 ASSERT_NE(EOF, putc_unlocked('a', fp)); in TEST()
2624 ASSERT_NE(EOF, putc('b', fp)); in TEST()
2625 ASSERT_NE(EOF, fputc_unlocked('c', fp)); in TEST()
2626 ASSERT_NE(EOF, fputc('d', fp)); in TEST()
2628 rewind(fp); in TEST()
2629 ASSERT_EQ('a', getc_unlocked(fp)); in TEST()
2630 ASSERT_EQ('b', getc(fp)); in TEST()
2631 ASSERT_EQ('c', fgetc_unlocked(fp)); in TEST()
2632 ASSERT_EQ('d', fgetc(fp)); in TEST()
2634 rewind(fp); in TEST()
2635 ASSERT_EQ(2U, fwrite_unlocked("AB", 1, 2, fp)); in TEST()
2636 ASSERT_EQ(2U, fwrite("CD", 1, 2, fp)); in TEST()
2637 ASSERT_EQ(0, fflush_unlocked(fp)); in TEST()
2639 rewind(fp); in TEST()
2641 ASSERT_EQ(2U, fread_unlocked(&buf[0], 1, 2, fp)); in TEST()
2642 ASSERT_EQ(2U, fread(&buf[2], 1, 2, fp)); in TEST()
2645 rewind(fp); in TEST()
2646 ASSERT_NE(EOF, fputs("hello ", fp)); in TEST()
2647 ASSERT_NE(EOF, fputs_unlocked("world", fp)); in TEST()
2648 ASSERT_NE(EOF, fputc('\n', fp)); in TEST()
2650 rewind(fp); in TEST()
2651 ASSERT_TRUE(fgets_unlocked(buf, sizeof(buf), fp) != nullptr); in TEST()
2654 ASSERT_EQ(0, fclose(fp)); in TEST()
2659 FILE* fp = fopen64(tf.path, "w+"); in TEST() local
2660 ASSERT_TRUE(fp != nullptr); in TEST()
2661 ASSERT_EQ(0, fseeko64(fp, 0x2'0000'0000, SEEK_SET)); in TEST()
2662 ASSERT_EQ(0x2'0000'0000, ftello64(fp)); in TEST()
2663 ASSERT_EQ(0, fseeko64(fp, 0x1'0000'0000, SEEK_CUR)); in TEST()
2664 ASSERT_EQ(0x3'0000'0000, ftello64(fp)); in TEST()
2665 ASSERT_EQ(0, fclose(fp)); in TEST()
2672 FILE* fp = fopen64(tf.path, "w+"); in TEST() local
2673 ASSERT_EQ(0, ftruncate64(fileno(fp), 0x2'0000'0000)); in TEST()
2677 ASSERT_EQ(0, fseek(fp, 0x7fff'ffff, SEEK_SET)); in TEST()
2678 ASSERT_EQ(-1, fseek(fp, 1, SEEK_CUR)); in TEST()
2685 ASSERT_EQ(0, fseek(fp, 0, SEEK_END)); in TEST()
2686 ASSERT_EQ(0x2'0000'0000, ftello64(fp)); in TEST()
2688 fclose(fp); in TEST()
2813 FILE* fp; in TEST() local
2819 fp = fdopen(fd, "nonsense"); in TEST()
2820 ASSERT_TRUE(fp == nullptr); in TEST()
2825 fp = fdopen(fd, "w"); in TEST()
2826 ASSERT_TRUE(fp == nullptr); in TEST()
2831 fp = fdopen(fd, "a"); in TEST()
2832 ASSERT_TRUE(fp == nullptr); in TEST()
2837 fp = fdopen(-1, "re"); in TEST()
2838 ASSERT_TRUE(fp == nullptr); in TEST()
2846 FILE* fp = fmemopen(nullptr, 16, "nonsense"); in TEST() local
2847 ASSERT_TRUE(fp == nullptr); in TEST()
2853 FILE* fp = fopen("/proc/version", "nonsense"); in TEST() local
2854 ASSERT_TRUE(fp == nullptr); in TEST()
2859 FILE* fp = fopen("/proc/version", "re"); in TEST() local
2860 ASSERT_TRUE(fp != nullptr); in TEST()
2863 fp = freopen("/proc/version", "nonsense", fp); in TEST()
2864 ASSERT_TRUE(fp == nullptr); in TEST()
2877 FILE* fp = fopen("/proc/does-not-exist", "re"); in TEST() local
2878 ASSERT_TRUE(fp == nullptr); in TEST()
2950 FILE* fp = fopen(tf.path, "r"); in TEST() local
2951 ASSERT_TRUE(fp != nullptr); in TEST()
2955 ASSERT_EQ(0, read(fileno(fp), buf, 1)); in TEST()
2956 ASSERT_EQ(-1, write(fileno(fp), "hello", 1)); in TEST()
2958 fp = freopen(nullptr, "r+", fp); in TEST()
2959 ASSERT_EQ(0, read(fileno(fp), buf, 1)); in TEST()
2960 ASSERT_EQ(1, write(fileno(fp), "hello", 1)); in TEST()
2962 fp = freopen(nullptr, "w", fp); in TEST()
2963 ASSERT_EQ(-1, read(fileno(fp), buf, 1)); in TEST()
2964 ASSERT_EQ(1, write(fileno(fp), "hello", 1)); in TEST()
2966 fclose(fp); in TEST()
2983 std::unique_ptr<FILE, decltype(&fclose)> fp{fopen("/dev/zero", "re"), fclose}; in TEST()
2984 ASSERT_EQ(too_big_for_an_int, fread(&buf[0], 1, too_big_for_an_int, fp.get())); in TEST()
2996 std::unique_ptr<FILE, decltype(&fclose)> fp{fopen("/dev/null", "we"), fclose}; in TEST()
2997 ASSERT_EQ(too_big_for_an_int, fwrite(&buf[0], 1, too_big_for_an_int, fp.get())); in TEST()