662TEST_F(FileSystemTest, hardLinkCount)
663{
664 auto linkCount = FileSystem::hardLinkCount(tempFilePath());
665 ASSERT_TRUE(!!linkCount);
666 EXPECT_EQ(*linkCount, 1U);
667
668 auto hardlink1Path = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "tempFile-hardlink1");
669 EXPECT_TRUE(FileSystem::hardLink(tempFilePath(), hardlink1Path));
670 linkCount = FileSystem::hardLinkCount(tempFilePath());
671 ASSERT_TRUE(!!linkCount);
672 EXPECT_EQ(*linkCount, 2U);
673
674 auto hardlink2Path = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "tempFile-hardlink2");
675 EXPECT_TRUE(FileSystem::hardLink(tempFilePath(), hardlink2Path));
676 linkCount = FileSystem::hardLinkCount(tempFilePath());
677 ASSERT_TRUE(!!linkCount);
678 EXPECT_EQ(*linkCount, 3U);
679
680 EXPECT_TRUE(FileSystem::deleteFile(hardlink1Path));
681 linkCount = FileSystem::hardLinkCount(tempFilePath());
682 ASSERT_TRUE(!!linkCount);
683 EXPECT_EQ(*linkCount, 2U);
684
685 EXPECT_TRUE(FileSystem::deleteFile(hardlink2Path));
686 linkCount = FileSystem::hardLinkCount(tempFilePath());
687 ASSERT_TRUE(!!linkCount);
688 EXPECT_EQ(*linkCount, 1U);
689
690 EXPECT_TRUE(FileSystem::deleteFile(tempFilePath()));
691 linkCount = FileSystem::hardLinkCount(tempFilePath());
692 EXPECT_TRUE(!linkCount);
693}
694