1 #include <gtest/gtest.h> 2 #include <stdio.h> 3 using namespace testing::ext; 4 5 class StdioFputcunlockedTest : public testing::Test { SetUp()6 void SetUp() override {} TearDown()7 void TearDown() override {} 8 }; 9 constexpr int NUM = 65; 10 /** 11 * @tc.name: fputc_unlocked_001 12 * @tc.desc: Ensure that the fputc_unlocked() function correctly writes a character to a file without any 13 * locking mechanisms. 14 * @tc.type: FUNC 15 **/ 16 HWTEST_F(StdioFputcunlockedTest, fputc_unlocked_001, TestSize.Level1) 17 { 18 FILE* file; 19 char ch = 'A'; 20 file = fopen("/proc/version", "w"); 21 ASSERT_NE(nullptr, file); 22 int result = fputc_unlocked(ch, file); 23 EXPECT_EQ(NUM, result); 24 fclose(file); 25 }