1 #include <gtest/gtest.h> 2 #include <locale.h> 3 4 using namespace testing::ext; 5 6 class LocaleUselocaleTest : public testing::Test { SetUp()7 void SetUp() override {} TearDown()8 void TearDown() override {} 9 }; 10 11 /** 12 * @tc.name: uselocale_001 13 * @tc.desc: This test verifies the behavior of the uselocal function on switching and obtaining the current local. 14 * @tc.type: FUNC 15 */ 16 HWTEST_F(LocaleUselocaleTest, uselocale_001, TestSize.Level1) 17 { 18 locale_t initialLocale = uselocale(nullptr); 19 ASSERT_NE(initialLocale, nullptr); 20 locale_t newLocale = newlocale(LC_ALL, "C", nullptr); 21 ASSERT_NE(newLocale, nullptr); 22 ASSERT_NE(newLocale, initialLocale); 23 locale_t previousLocale = uselocale(newLocale); 24 ASSERT_NE(previousLocale, nullptr); 25 ASSERT_EQ(previousLocale, initialLocale); 26 ASSERT_EQ(newLocale, uselocale(nullptr)); 27 }