hidl_version: add operator!=
This was missing and was needed for a CL internally.
Test: libhidl_test
Change-Id: Ib2cadbfc69b42b6c1ead8a8658adfa40d3ce2a3b
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 8c93998..7a5183b 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -845,6 +845,10 @@
return (mMajor == other.get_major() && mMinor == other.get_minor());
}
+ bool operator!=(const hidl_version& other) const {
+ return !(*this == other);
+ }
+
bool operator<(const hidl_version& other) const {
return (mMajor < other.get_major() ||
(mMajor == other.get_major() && mMinor < other.get_minor()));
diff --git a/test_main.cpp b/test_main.cpp
index 0de46ec..7f80d71 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -390,12 +390,15 @@
hidl_version v3_0b{3,0};
EXPECT_TRUE(v1_0 < v2_0);
+ EXPECT_TRUE(v1_0 != v2_0);
EXPECT_TRUE(v2_0 < v2_1);
EXPECT_TRUE(v2_1 < v3_0);
EXPECT_TRUE(v2_0 > v1_0);
+ EXPECT_TRUE(v2_0 != v1_0);
EXPECT_TRUE(v2_1 > v2_0);
EXPECT_TRUE(v3_0 > v2_1);
EXPECT_TRUE(v3_0 == v3_0b);
+ EXPECT_FALSE(v3_0 != v3_0b);
EXPECT_TRUE(v3_0 <= v3_0b);
EXPECT_TRUE(v2_2 <= v3_0);
EXPECT_TRUE(v3_0 >= v3_0b);