• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <gtest/gtest.h>
2 #include <langinfo.h>
3 #include <locale.h>
4 
5 using namespace testing::ext;
6 
7 class LocaleNllanginfolTest : public ::testing::Test {
SetUp()8     void SetUp() override {}
TearDown()9     void TearDown() override {}
10 };
11 
12 /**
13  * @tc.name: nl_langinfo_l_001
14  * @tc.desc: This test verifies that after setting a specific locale, nl is called langinfo_l function obtains the
15  *           decimal separator and ensures that valid decimal separator information can be successfully obtained.
16  * @tc.type: FUNC
17  */
18 HWTEST_F(LocaleNllanginfolTest, nl_langinfo_l_001, TestSize.Level1)
19 {
20     setlocale(LC_ALL, "A");
21     locale_t testLocale = newlocale(LC_ALL, "A", nullptr);
22     const char* decimalSeparator = nl_langinfo_l(RADIXCHAR, testLocale);
23     ASSERT_NE(decimalSeparator, nullptr);
24     if (decimalSeparator != nullptr) {
25         EXPECT_TRUE(strlen(decimalSeparator) > 0);
26     } else {
27         FAIL() << "Failed to retrieve decimal point information";
28     }
29     freelocale(testLocale);
30 }