[gparted] Add BlockSpecial operator<() tests (#781978)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Add BlockSpecial operator<() tests (#781978)
- Date: Fri, 2 Jun 2017 17:24:17 +0000 (UTC)
commit 003d1b54c7b25c7e0aa367cb46c8ba60c5abde7a
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Mon May 8 19:19:12 2017 +0100
Add BlockSpecial operator<() tests (#781978)
Bug 781978 - Add Google Test C++ test framework
tests/test_BlockSpecial.cc | 98 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 97 insertions(+), 1 deletions(-)
---
diff --git a/tests/test_BlockSpecial.cc b/tests/test_BlockSpecial.cc
index d204573..3d25dad 100644
--- a/tests/test_BlockSpecial.cc
+++ b/tests/test_BlockSpecial.cc
@@ -354,6 +354,102 @@ TEST( BlockSpecialTest, OperatorEqualsSameBlockDevicesWithMinorZero )
EXPECT_TRUE( bs1 == bs2 );
}
-// FIXME: Write tests to fully check operator<() is working as intended.
+TEST( BlockSpecialTest, OperatorLessThanTwoEmptyObjects )
+{
+ // Test one empty BlockSpecial object is not ordered before another empty one.
+ BlockSpecial::clear_cache();
+ BlockSpecial bs1;
+ BlockSpecial bs2;
+ EXPECT_FALSE( bs1 < bs2 );
+}
+
+TEST( BlockSpecialTest, OperatorLessThanSamePlainFiles )
+{
+ // Test one plain file BlockSpecial object is not ordered before another of the
+ // same name.
+ BlockSpecial::clear_cache();
+ BlockSpecial bs1( "/" );
+ BlockSpecial bs2( "/" );
+ EXPECT_FALSE( bs1 < bs2 );
+}
+
+TEST( BlockSpecialTest, OperatorLessThanDifferentPlainFiles )
+{
+ // Test one plain file BlockSpecial object with the lower name is ordered before
+ // the other plain file with a higher name.
+ BlockSpecial::clear_cache();
+ BlockSpecial::register_block_special( "/dummy_file1", 0, 0 );
+ BlockSpecial::register_block_special( "/dummy_file2", 0, 0 );
+ BlockSpecial bs1( "/dummy_file1" );
+ BlockSpecial bs2( "/dummy_file2" );
+ EXPECT_TRUE( bs1 < bs2 );
+}
+
+TEST( BlockSpecialTest, OperatorLessThanEmptyObjectAndPlainFile )
+{
+ // Test empty BlockSpecial object with name "" is before a plain file of any name.
+ BlockSpecial::clear_cache();
+ BlockSpecial bs1;
+ BlockSpecial bs2( "/" );
+ EXPECT_TRUE( bs1 < bs2 );
+}
+
+TEST( BlockSpecialTest, OperatorLessThanSameBlockDevices )
+{
+ std::string bname = get_block_name( 0 );
+
+ // Test one name block device BlockSpecial object is not ordered before another
+ // from the same name.
+ BlockSpecial::clear_cache();
+ BlockSpecial bs1( bname );
+ BlockSpecial bs2( bname );
+ EXPECT_FALSE( bs1 < bs2 );
+}
+
+TEST( BlockSpecialTest, OperatorLessThanEmptyObjectAndBlockDevice )
+{
+ std::string bname = get_block_name( 0 );
+
+ // Test empty BlockSpecial object with name "" is before any block device.
+ BlockSpecial::clear_cache();
+ BlockSpecial bs1;
+ BlockSpecial bs2( bname );
+ EXPECT_TRUE( bs1 < bs2 );
+}
+
+TEST( BlockSpecialTest, OperatorLessThanPlainFileAndBlockDevice )
+{
+ std::string bname = get_block_name( 0 );
+
+ // Test one plain file BlockSpecial object is ordered before any block device.
+ BlockSpecial::clear_cache();
+ BlockSpecial bs1( "/" );
+ BlockSpecial bs2( bname );
+ EXPECT_TRUE( bs1 < bs2 );
+}
+
+TEST( BlockSpecialTest, OperatorLessThanTwoDifferentBlockDevicesMajorNumbers )
+{
+ // Test one block device BlockSpecial object is ordered before another based on
+ // major numbers.
+ BlockSpecial::clear_cache();
+ BlockSpecial::register_block_special( "/dummy_block2", 1, 1 );
+ BlockSpecial::register_block_special( "/dummy_block1", 2, 0 );
+ BlockSpecial bs1( "/dummy_block2" );
+ BlockSpecial bs2( "/dummy_block1" );
+ EXPECT_TRUE( bs1 < bs2 );
+}
+
+TEST( BlockSpecialTest, OperatorLessThanTwoDifferentBlockDevicesMinorNumbers )
+{
+ // Test one block device BlockSpecial object is ordered before another based on
+ // minor numbers.
+ BlockSpecial::clear_cache();
+ BlockSpecial::register_block_special( "/dummy_block2", 2, 0 );
+ BlockSpecial::register_block_special( "/dummy_block1", 2, 1 );
+ BlockSpecial bs1( "/dummy_block2" );
+ BlockSpecial bs2( "/dummy_block1" );
+ EXPECT_TRUE( bs1 < bs2 );
+}
} // namespace GParted
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]