[glibmm] tests/glibmm_variant: Test operator==() and operator!=()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] tests/glibmm_variant: Test operator==() and operator!=()
- Date: Tue, 14 Nov 2017 16:04:58 +0000 (UTC)
commit a22636174d8a9ec755694309dc40a71c1e794e41
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Tue Nov 14 17:01:27 2017 +0100
tests/glibmm_variant: Test operator==() and operator!=()
Bug 789330
tests/glibmm_variant/main.cc | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/tests/glibmm_variant/main.cc b/tests/glibmm_variant/main.cc
index 0836ec2..f3d4e26 100644
--- a/tests/glibmm_variant/main.cc
+++ b/tests/glibmm_variant/main.cc
@@ -120,6 +120,38 @@ bool test_object_path()
return result_ok;
}
+bool test_comparison()
+{
+ bool result_ok = true;
+
+ std::vector<int> int_vector1 = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ std::vector<int> int_vector2 = { 1, 2, 3, 4, 5, 6, 7 };
+
+ auto int_variant1 = Glib::Variant<std::vector<int>>::create(int_vector1);
+ auto int_variant2 = Glib::Variant<std::vector<int>>::create(int_vector2);
+ auto int_variant3 = Glib::Variant<std::vector<int>>::create(int_vector1);
+
+ // Equality and inequality operators
+ ostr << "int_variant1 == int_variant2 (0): " << (int_variant1 == int_variant2) << std::endl;
+ result_ok &= !(int_variant1 == int_variant2);
+ ostr << "int_variant1 != int_variant2 (1): " << (int_variant1 != int_variant2) << std::endl;
+ result_ok &= (int_variant1 != int_variant2);
+
+ ostr << "int_variant1 == int_variant3 (1): " << (int_variant1 == int_variant3) << std::endl;
+ result_ok &= (int_variant1 == int_variant3);
+ ostr << "int_variant1 != int_variant3 (0): " << (int_variant1 != int_variant3) << std::endl;
+ result_ok &= !(int_variant1 != int_variant3);
+
+#if 0
+ // Less than (activate if operator<() exists)
+ ostr << "int_variant2 < int_variant1 (1): " << (int_variant2 < int_variant1) << std::endl;
+ result_ok &= (int_variant2 < int_variant1);
+ ostr << "int_variant1 < int_variant3 (0): " << (int_variant1 < int_variant3) << std::endl;
+ result_ok &= !(int_variant1 < int_variant3);
+#endif
+ return result_ok;
+}
+
} // anonymous namespace
int
@@ -276,6 +308,7 @@ main(int, char**)
bool result_ok = test_tuple();
result_ok &= test_object_path();
+ result_ok &= test_comparison();
return result_ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]