From f4008092dd99969299bef05b975a00f654026c4c Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Sun, 7 May 2017 14:18:27 +0100 Subject: [PATCH] Add test for bug #771670 in BlockSpecial::operator==() (#781978) Add a specific test for the failure found in bug 771670 and fixed by commit: 253c4d641687f21a4656af0926af18371d47d654 Fix BlockSpecial comparison (#771670) Bug 781978 - Add Google Test C++ test framework --- tests/test_BlockSpecial.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_BlockSpecial.cc b/tests/test_BlockSpecial.cc index 1f82367d..d2045732 100644 --- a/tests/test_BlockSpecial.cc +++ b/tests/test_BlockSpecial.cc @@ -342,6 +342,18 @@ TEST( BlockSpecialTest, OperatorEqualsTwoDifferentBlockDevices ) EXPECT_FALSE( bs1 == bs2 ); } +TEST( BlockSpecialTest, OperatorEqualsSameBlockDevicesWithMinorZero ) +{ + // Test for fix in bug #771670. Ensure that block devices with minor number 0 are + // compared by major, minor pair rather than by name. + BlockSpecial::clear_cache(); + BlockSpecial::register_block_special( "/dev/mapper/encrypted_swap", 254, 0 ); + BlockSpecial::register_block_special( "/dev/dm-0", 254, 0 ); + BlockSpecial bs1( "/dev/mapper/encrypted_swap" ); + BlockSpecial bs2( "/dev/dm-0" ); + EXPECT_TRUE( bs1 == bs2 ); +} + // FIXME: Write tests to fully check operator<() is working as intended. } // namespace GParted