• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <gtest/gtest.h>
2 #include <locale.h>
3 
4 using namespace testing::ext;
5 
6 class LocaleStrtoflTest : public ::testing::Test {
SetUp()7     void SetUp() override {}
TearDown()8     void TearDown() override {}
9 };
10 
11 /**
12  * @tc.name: strtof_l_001
13  * @tc.desc: This test is validated by using strtof_ Verify that the input string "100.1" can be correctly converted to
14  *           the corresponding floating-point value 100.1 using the l function and specific localization environment.
15  * @tc.type: FUNC
16  */
17 HWTEST_F(LocaleStrtoflTest, strtof_l_001, TestSize.Level1)
18 {
19     const char* inputValue = "100.1";
20     char* lastptr;
21     locale_t locale = newlocale(LC_ALL_MASK, "A", nullptr);
22     float endresult = strtof_l(inputValue, &lastptr, locale);
23     EXPECT_FLOAT_EQ(endresult, 100.1f);
24     freelocale(locale);
25 }