| 152 | } |
| 153 | |
| 154 | TEST(TestInfo, Sort) |
| 155 | { |
| 156 | std::vector<CTestInfoPath> vEntries; |
| 157 | vEntries.resize(3); |
| 158 | |
| 159 | const char aBasePath[] = "test_dir"; |
| 160 | const char aSubPath[] = "test_dir/subdir"; |
| 161 | const char aFilePath[] = "test_dir/subdir/file.txt"; |
| 162 | |
| 163 | vEntries[0].m_IsDirectory = true; |
| 164 | str_copy(vEntries[0].m_aData, aBasePath); |
| 165 | |
| 166 | vEntries[1].m_IsDirectory = true; |
| 167 | str_copy(vEntries[1].m_aData, aSubPath); |
| 168 | |
| 169 | vEntries[2].m_IsDirectory = false; |
| 170 | str_copy(vEntries[2].m_aData, aFilePath); |
| 171 | |
| 172 | // Sorts directories after files. |
| 173 | std::sort(vEntries.begin(), vEntries.end()); |
| 174 | |
| 175 | EXPECT_FALSE(vEntries[0].m_IsDirectory); |
| 176 | EXPECT_EQ(str_comp(vEntries[0].m_aData, aFilePath), 0); |
| 177 | EXPECT_TRUE(vEntries[1].m_IsDirectory); |
| 178 | EXPECT_EQ(str_comp(vEntries[1].m_aData, aSubPath), 0); |
| 179 | EXPECT_TRUE(vEntries[2].m_IsDirectory); |
| 180 | EXPECT_EQ(str_comp(vEntries[2].m_aData, aBasePath), 0); |
| 181 | } |