• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <gtest/gtest.h>
2 #include <stdio.h>
3 using namespace testing::ext;
4 
5 class StdioFpurgeTest : public testing::Test {
SetUp()6     void SetUp() override {}
TearDown()7     void TearDown() override {}
8 };
9 
10 extern "C" int fpurge(FILE*);
11 /**
12  * @tc.name: fpurge_001
13  * @tc.desc: Ensure that the fpurge() function correctly discards any buffered data in the file stream.
14  * @tc.type: FUNC
15  **/
16 HWTEST_F(StdioFpurgeTest, fpurge_001, TestSize.Level1)
17 {
18     FILE* file = fopen("test_fpurge.txt", "w+");
19     ASSERT_NE(nullptr, file);
20     fputs("Hello, World!", file);
21     int result = fpurge(file);
22     EXPECT_EQ(0, result);
23     fclose(file);
24 }