1 #include <gtest/gtest.h> 2 #include <stdio.h> 3 using namespace testing::ext; 4 5 class StdioFflushunlockedTest : public testing::Test { SetUp()6 void SetUp() override {} TearDown()7 void TearDown() override {} 8 }; 9 10 /** 11 * @tc.name: fflush_unlocked_001 12 * @tc.desc: Ensure that the fflush_unlocked() function correctly flushes any buffered output to the file. 13 * @tc.type: FUNC 14 **/ 15 HWTEST_F(StdioFflushunlockedTest, fflush_unlocked_001, TestSize.Level1) 16 { 17 FILE* file = fopen("test_fflush_unlocked", "w"); 18 ASSERT_NE(nullptr, file); 19 fprintf(file, "This is a test message\n"); 20 int result = fflush_unlocked(file); 21 EXPECT_EQ(0, result); 22 fclose(file); 23 }