• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <dirent.h>
2 #include <gtest/gtest.h>
3 
4 using namespace testing::ext;
5 
6 class DirentAlphasort64Test : public testing::Test {
SetUp()7     void SetUp() override {}
TearDown()8     void TearDown() override {}
9 };
10 
11 /**
12  * @tc.name: alphasort64_001
13  * @tc.desc: Test alphasort is passed as a callback function parameter to scandir to test the effect of alphasort
14  * @tc.type: FUNC
15  **/
16 HWTEST_F(DirentAlphasort64Test, alphasort64_001, TestSize.Level1)
17 {
18     struct dirent** nameList;
19     int n = scandir(".", &nameList, nullptr, alphasort64);
20 
21     EXPECT_GE(n, 0);
22     if (n < 0) {
23         perror("scandir");
24     } else {
25         while (n--) {
26             free(nameList[n]);
27         }
28         free(nameList);
29     }
30 }