/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
END_TEST;
}
+
+/** Comparision of two different types*/
+int UtcDaliIntrusivePtrOperatorLessTU(void)
+{
+ tet_infoline("Test for Dali::IntrusivePtr::operator <(T, U)");
+
+ IntrusivePtr<Counted> counted1(new Counted);
+ IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
+ IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
+ IntrusivePtr<Counted> counted2(countedSubclass2);
+
+ const bool expectResult = counted1.Get() < countedSubclass1.Get();
+
+ DALI_TEST_EQUALS(operator<(counted1, countedSubclass1), expectResult, TEST_LOCATION);
+ DALI_TEST_EQUALS(operator<(countedSubclass1, counted1), !expectResult, TEST_LOCATION);
+ DALI_TEST_EQUALS(operator<(counted2, countedSubclass2), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(operator<(countedSubclass2, counted2), false, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliIntrusivePtrOperatorLessRightPointerTU(void)
+{
+ tet_infoline("Test for Dali::IntrusivePtr::operator <(T, U*)");
+
+ IntrusivePtr<Counted> counted1(new Counted);
+ IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
+ IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
+ IntrusivePtr<Counted> counted2(countedSubclass2);
+
+ const bool expectResult = counted1.Get() < countedSubclass1.Get();
+
+ DALI_TEST_EQUALS(operator<(counted1, countedSubclass1.Get()), expectResult, TEST_LOCATION);
+ DALI_TEST_EQUALS(operator<(countedSubclass1, counted1.Get()), !expectResult, TEST_LOCATION);
+ DALI_TEST_EQUALS(operator<(counted2, countedSubclass2.Get()), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(operator<(countedSubclass2, counted2.Get()), false, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliIntrusivePtrOperatorLessLeftPointerTU(void)
+{
+ tet_infoline("Test for Dali::IntrusivePtr::operator <(T*, U)");
+
+ IntrusivePtr<Counted> counted1(new Counted);
+ IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
+ IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
+ IntrusivePtr<Counted> counted2(countedSubclass2);
+
+ const bool expectResult = counted1.Get() < countedSubclass1.Get();
+
+ DALI_TEST_EQUALS(operator<(counted1.Get(), countedSubclass1), expectResult, TEST_LOCATION);
+ DALI_TEST_EQUALS(operator<(countedSubclass1.Get(), counted1), !expectResult, TEST_LOCATION);
+ DALI_TEST_EQUALS(operator<(counted2.Get(), countedSubclass2), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(operator<(countedSubclass2.Get(), counted2), false, TEST_LOCATION);
+ END_TEST;
+}
+
+/** Comparision with nullptr */
+int UtcDaliIntrusivePtrOperatorLessWithNullptr(void)
+{
+ tet_infoline("Test for Dali::IntrusivePtr::operator < nullptr");
+
+ IntrusivePtr<Counted> counted1(new Counted);
+
+ // counted1 is not nullptr.
+ DALI_TEST_CHECK(!(counted1 < nullptr));
+ DALI_TEST_CHECK(nullptr < counted1);
+
+ counted1 = nullptr;
+
+ // counted1 is nullptr.
+ DALI_TEST_CHECK(!(counted1 < nullptr));
+ DALI_TEST_CHECK(!(nullptr < counted1));
+
+ END_TEST;
+}
\ No newline at end of file
#define DALI_INTRUSIVE_PTR_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
/**
+ * @brief Comparison overrides of objects wrapped by intrusive pointers.
+ *
+ * @SINCE_2_3.35
+ * @param[in] lhs Intrusive pointer to compare with
+ * @param[in] rhs Intrusive pointer to compare against
+ * @return True if the pointers point of rhs is bigger than lhs
+ */
+template<typename T, typename U>
+inline bool operator<(IntrusivePtr<T> const& lhs, IntrusivePtr<U> const& rhs)
+{
+ return lhs.Get() < rhs.Get();
+}
+
+/**
+ * @brief Comparison overrides of objects wrapped by intrusive pointers.
+ *
+ * @SINCE_2_3.35
+ * @param[in] lhs Object to compare with
+ * @param[in] rhs Intrusive pointer to compare against
+ * @return True if the pointers point of rhs is bigger than lhs
+ */
+template<typename T, typename U>
+inline bool operator<(T* lhs, IntrusivePtr<U> const& rhs)
+{
+ return lhs < rhs.Get();
+}
+
+/**
+ * @brief Comparison overrides of objects wrapped by intrusive pointers.
+ *
+ * @SINCE_2_3.35
+ * @param[in] lhs Intrusive pointer to compare with
+ * @param[in] rhs Object to compare against
+ * @return True if the pointers point of rhs is bigger than lhs
+ */
+template<typename T, typename U>
+inline bool operator<(IntrusivePtr<T> const& lhs, U* rhs)
+{
+ return lhs.Get() < rhs;
+}
+
+/**
+ * @brief Comparison overrides of objects wrapped by intrusive pointers.
+ *
+ * @SINCE_2_3.35
+ * @param[in] lhs nullptr
+ * @param[in] rhs Intrusive pointer to compare against
+ * @return True if the pointers point of rhs is bigger than lhs
+ */
+template<typename T>
+inline bool operator<(std::nullptr_t lhs, IntrusivePtr<T> const& rhs)
+{
+ return nullptr < rhs.Get();
+}
+
+/**
+ * @brief Comparison overrides of objects wrapped by intrusive pointers.
+ *
+ * @SINCE_2_3.35
+ * @param[in] lhs Intrusive pointer to compare with
+ * @param[in] rhs nullptr
+ * @return True if the pointers point of rhs is bigger than lhs
+ */
+template<typename T>
+inline bool operator<(IntrusivePtr<T> const& lhs, std::nullptr_t rhs)
+{
+ return lhs.Get() < nullptr;
+}
+
+/**
* @}
*/
} // namespace Dali