2#ifndef _aspose_system_test_tools_compare_h_
3#define _aspose_system_test_tools_compare_h_
5#include "system/array.h"
6#include "system/collections/list.h"
7#include "system/collections/dictionary.h"
8#include "system/collections/hashset.h"
9#include "system/collections/queue.h"
10#include "system/collections/stack.h"
11#include "system/collections/sorted_dictionary.h"
12#include "system/collections/sorted_list.h"
13#include "system/collections/bitarray.h"
14#include "system/collections/ienumerable.h"
15#include "system/collections/specialized/string_collection.h"
17#include <system/boxed_value.h>
19#include <system/date_time.h>
20#include <system/timespan.h>
21#include <system/decimal.h>
22#include <system/guid.h>
38 template <
typename T,
typename =
void>
54 struct IsEnumerable<
System::
SharedPtr<X>,
void_t<typename X::ValueType, std::enable_if_t<std::is_base_of<
55 System::Collections::Generic::IEnumerable<typename X::ValueType>, X>::value>>>
65 return obj->GetEnumerator();
82 template <
typename T,
typename U>
85 return AreEqualData(arrA, arrB);
93 template <
typename T,
typename U>
97 if ((
void*)arrA.GetObjectOrNull() == (
void*)arrB.GetObjectOrNull())
103 return AreEqualContainerOfObjects(arrA->data(), arrB->data());
113 template <
typename T,
typename U>
116 return AreEqualData(listA, listB);
124 template <
typename T,
typename U>
128 if ((
void*)listA.GetObjectOrNull() == (
void*)listB.GetObjectOrNull())
131 if (!listA || !listB)
134 return AreEqualContainerOfObjects(listA->data(), listB->data());
144 template <
typename T,
typename U>
147 return AreEqualData(listA, arrB);
155 template <
typename T,
typename U>
158 return AreEqualData(arrA, listB);
166 template <
typename T,
typename U>
170 if ((
void*)arr.GetObjectOrNull() == (
void*)list.GetObjectOrNull())
176 return AreEqualContainerOfObjects(arr->data(), list->data());
184 template <
typename T,
typename U>
188 if ((
void*)list.GetObjectOrNull() == (
void*)arr.GetObjectOrNull())
194 return AreEqualContainerOfObjects(list->data(), arr->data());
204 template <
typename K,
typename U>
207 return AreEqualData(dictA, dictB);
215 template <
typename K,
typename U>
219 if ((
void*)dictA.GetObjectOrNull() == (
void*)dictB.GetObjectOrNull())
222 if (!dictA || !dictB)
225 return AreEqualMapOfObjects(dictA->data(), dictB->data());
235 template <
typename K1,
typename U1,
typename K2,
typename U2>
238 ASPOSE_UNUSED(dictA);
239 ASPOSE_UNUSED(dictB);
250 template <
typename T,
typename U>
253 if ((
void*)containerPtrA.GetObjectOrNull() == (
void*)containerPtrB.GetObjectOrNull())
256 if (!containerPtrA || !containerPtrB)
259 if (containerPtrA->data().size() != containerPtrB->data().size())
262 return std::equal(containerPtrA->data().begin(), containerPtrA->data().end(), containerPtrB->data().begin());
270 template <
typename T,
typename U>
274 if ((
void*)contA.GetObjectOrNull() == (
void*)contB.GetObjectOrNull())
277 if (!contA || !contB)
280 return AreEqualContainerOfObjects(contA->data(), contB->data());
290 template <
typename T,
typename U>
293 return AreEqualData(queueA, queueB);
301 template <
typename T,
typename U>
305 if ((
void*)queueA.GetObjectOrNull() == (
void*)queueB.GetObjectOrNull())
308 if (!queueA || !queueB)
311 return AreEqualContainerOfObjects(queueA->data(), queueB->data());
321 template <
typename T,
typename U>
324 return AreEqualData(stackA, stackB);
332 template <
typename T,
typename U>
336 if ((
void*)stackA.GetObjectOrNull() == (
void*)stackB.GetObjectOrNull())
339 if (!stackA || !stackB)
342 return AreEqualContainerOfObjects(stackA->data(), stackB->data());
352 template <
typename K,
typename U>
355 return AreEqualData(dictA, dictB);
363 template <
typename K,
typename U>
367 if ((
void*)dictA.GetObjectOrNull() == (
void*)dictB.GetObjectOrNull())
370 if (!dictA || !dictB)
373 return AreEqualMapOfObjects(dictA->data(), dictB->data());
383 template <
typename K1,
typename U1,
typename K2,
typename U2>
396 template <
typename K,
typename U>
399 return AreEqualData(dictA, dictB);
407 template <
typename K,
typename U>
411 if ((
void*)dictA.GetObjectOrNull() == (
void*)dictB.GetObjectOrNull())
414 if (!dictA || !dictB)
417 return AreEqualMapOfObjects(dictA->data(), dictB->data());
427 template <
typename K1,
typename U1,
typename K2,
typename U2>
440 return AreEqualData(arrA, arrB);
448 template <
typename T,
typename U>
451 auto tenum = et->GetEnumerator();
452 auto uenum = eu->GetEnumerator();
454 while (tenum->MoveNext())
456 if (!uenum->MoveNext())
460 if (!AreEqualObjects(tenum->get_Current(), uenum->get_Current()))
465 return !uenum->MoveNext();
474 template <
typename T>
482 if (!collA || !collB)
494 while (enA->MoveNext() && enB->MoveNext())
496 auto&& itA = enA->get_Current();
497 auto&& itB = enB->get_Current();
512 template <
typename T>
513 static bool AreEqualData(
const SharedPtr<T>& containerPtrA,
516 if (containerPtrA == containerPtrB)
519 if (!containerPtrA || !containerPtrB)
522 return containerPtrA->data() == containerPtrB->data();
530 template <
typename T,
typename U>
531 static bool AreEqualData(
const SharedPtr<T>& containerPtrA,
532 const SharedPtr<U>& containerPtrB)
534 if ((
void*)containerPtrA.GetObjectOrNull() == (
void*)containerPtrB.GetObjectOrNull())
537 if (!containerPtrA || !containerPtrB)
540 if (containerPtrA->data().size() != containerPtrB->data().size())
543 return std::equal(containerPtrA->data().begin(), containerPtrA->data().end(), containerPtrB->data().begin());
553 template <
typename T,
typename U>
554 static bool AreEqualObjects(
const T& ptrA,
const U& ptrB)
562 while ((more = enA->MoveNext()) == enB->MoveNext())
568 else if (!AreEqualObjects(enA->get_Current(), enB->get_Current()))
583 template <
typename K,
typename V>
584 static bool AreEqualObjectPairs(
const std::pair<K, V>& pairA,
const std::pair<K, V>& pairB)
594 template <
typename Tvect,
typename Uvect>
595 static bool AreEqualContainerOfObjects(Tvect& contA, Uvect& contB)
597 if (contA.size() != contB.size())
600 return std::equal(contA.begin(), contA.end(), contB.begin(),
601 TestCompare::AreEqualObjects<typename Tvect::value_type, typename Uvect::value_type>);
608 template <
typename Tmap>
609 static bool AreEqualMapOfObjects(
const Tmap& mapA,
const Tmap& mapB)
611 if (mapA.size() != mapB.size())
616 return std::equal(mapA.begin(), mapA.end(), mapB.begin(),
617 TestCompare::AreEqualObjectPairs<Tmap::key_type, Tmap::mapped_type>);
621 for (
typename Tmap::const_iterator itA = mapA.begin(); itA != mapA.end(); ++itA)
623 typename Tmap::const_iterator itF = mapB.find(itA->first);
624 if (itF == mapB.end() || !itF->second->Equals(itA->second))
634namespace CompareDetails {
636template <
typename X,
typename Y>
645 while ((more = enX->MoveNext()) == enY->MoveNext())
658 return System::Details::AreEqual(x, y);
Class that represents an array data structure. Objects of this class should only be allocated using S...
Definition: array.h:296
Forward declaration of Dictionary class.
Definition: dictionary.h:96
Forward declaration of HashSet class.
Definition: hashset.h:82
Interface of collection of elements. Objects of this class should only be allocated using System::Mak...
Definition: icollection.h:20
virtual int get_Count() const =0
Gets number of elements in collection.
Interface of object providing enumerator on contained elements.
Definition: ienumerable.h:26
virtual SharedPtr< IEnumerator< T > > GetEnumerator()=0
Gets enumerator.
Interface of enumerator which can be used to iterate through some elements. Objects of this class sho...
Definition: ienumerator.h:63
List forward declaration.
Definition: list.h:129
Queue pointer. This type is a pointer to manage other object's deletion. It should be allocated on st...
Definition: queue.h:26
Sorted dictionary type forward declaration.
Definition: sorted_dictionary.h:52
Sorted list wrapping FlatMap structure. Objects of this class should only be allocated using System::...
Definition: sorted_list.h:334
Stack class forward declaration.
Definition: stack.h:87
Stirng collection poiner with access operator.
Definition: string_collection.h:195
virtual bool Equals(ptr obj)
Compares objects using C# Object.Equals semantics.
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Baseclass for value types with Object inheritance being truncated for performance reasons....
Definition: value_type.h:17
Definition: algorithms.h:10
bool AreEqual(const X &x, const Y &y)
Definition: compare.h:637
Definition: db_command.h:9
Template predicate that checks if boxing of the specified type is supported.
Definition: boxable_traits.h:16
std::nullptr_t EnumeratorType
Definition: compare.h:41
Service structure providing interface to compare collections.
Definition: compare.h:32
static bool AreEqual(const SharedPtr< Array< T > > &arrA, const SharedPtr< Array< U > > &arrB)
Compares arrays of non-pointers.
Definition: compare.h:83
void void_t
Definition: compare.h:36
static bool AreEqual(const SCG::QueuePtr< T > &queueA, const SCG::QueuePtr< U > &queueB)
Compares queues of non-pointers.
Definition: compare.h:291
static bool AreEqual(const SharedPtr< SCG::List< SharedPtr< T > > > &listA, const SharedPtr< SCG::List< SharedPtr< U > > > &listB)
Compares lists of pointers.
Definition: compare.h:125
static bool AreEqual(const SharedPtr< SCG::SortedList< K, SharedPtr< U > > > &dictA, const SharedPtr< SCG::SortedList< K, SharedPtr< U > > > &dictB)
Compares sorted lists of pointer mapped types.
Definition: compare.h:408
static bool AreEqual(const SharedPtr< SCG::SortedList< K1, U1 > > &dictA, const SharedPtr< SCG::SortedList< K2, U2 > > &dictB)
Compares sorted lists of different types.
Definition: compare.h:428
static bool AreEqual(const System::ArrayPtr< T > &arrA, const SharedPtr< SCG::List< U > > &listB)
Compares lists with arrays in non-pointers elements case.
Definition: compare.h:156
static bool AreEqual(const SharedPtr< SCG::SortedList< K, U > > &dictA, const SharedPtr< SCG::SortedList< K, U > > &dictB)
Compares sorted lists of non-pointer mapped types.
Definition: compare.h:397
static bool AreEqual(const System::Collections::Specialized::StringCollectionPtr &arrA, const System::Collections::Specialized::StringCollectionPtr &arrB)
Compares string collections.
Definition: compare.h:438
static bool AreEqual(const SCG::QueuePtr< SharedPtr< T > > &queueA, const SCG::QueuePtr< SharedPtr< U > > &queueB)
Compares queues of pointers.
Definition: compare.h:302
static std::enable_if_t< IsEnumerable< T >::value, typename IsEnumerable< T >::EnumeratorType > GetEnumeratorOrNull(const T &obj)
Definition: compare.h:63
static bool AreEqual(const SharedPtr< SCG::List< T > > &listA, const SharedPtr< SCG::List< U > > &listB)
Compares lists of non-pointers.
Definition: compare.h:114
static bool AreEqual(const SharedPtr< SCG::HashSet< T > > &containerPtrA, const SharedPtr< SCG::HashSet< U > > &containerPtrB)
Compares hashsets of non-pointers.
Definition: compare.h:251
static bool AreEqual(const SharedPtr< SCG::List< T > > &listA, const System::ArrayPtr< U > &arrB)
Compares lists with arrays in non-pointers elements case.
Definition: compare.h:145
static bool AreEqual(const SharedPtr< SCG::SortedDictionary< K, U > > &dictA, const SharedPtr< SCG::SortedDictionary< K, U > > &dictB)
Compares sorted dictionaries of non-pointer mapped types.
Definition: compare.h:353
static bool AreEqual(const SharedPtr< Array< SharedPtr< T > > > &arrA, const SharedPtr< Array< SharedPtr< U > > > &arrB)
Compares arrays of pointers.
Definition: compare.h:94
static bool AreEqual(const SharedPtr< SCG::Stack< T > > &stackA, const SharedPtr< SCG::Stack< U > > &stackB)
Compares stacks of non-pointers.
Definition: compare.h:322
static bool AreEqual(const SharedPtr< SCG::Dictionary< K, U > > &dictA, const SharedPtr< SCG::Dictionary< K, U > > &dictB)
Compares dictionaries of non-pointer mapped types.
Definition: compare.h:205
static double & GetDefaultFloatingPointTolerance()
static bool AreEqual(const SharedPtr< SCG::SortedDictionary< K1, U1 > > &dictA, const SharedPtr< SCG::SortedDictionary< K2, U2 > > &dictB)
Compares sorted dictionaries of different types.
Definition: compare.h:384
static bool AreEqual(const System::ArrayPtr< SharedPtr< T > > &arr, const SharedPtr< SCG::List< SharedPtr< U > > > &list)
Compares lists with arrays in pointers elements case.
Definition: compare.h:167
static bool AreEqual(const SharedPtr< SCG::SortedDictionary< K, SharedPtr< U > > > &dictA, const SharedPtr< SCG::SortedDictionary< K, SharedPtr< U > > > &dictB)
Compares sorted dictionaries of pointer mapped types.
Definition: compare.h:364
static bool AreEqual(const SharedPtr< SCG::HashSet< SharedPtr< T > > > &contA, const SharedPtr< SCG::HashSet< SharedPtr< U > > > &contB)
Compares hashsets of pointers.
Definition: compare.h:271
static std::enable_if_t<!IsEnumerable< T >::value, System::Collections::Generic::IEnumerator< int > * > GetEnumeratorOrNull(const T &)
Definition: compare.h:70
static bool AreEqual(const SharedPtr< SCG::Stack< SharedPtr< T > > > &stackA, const SharedPtr< SCG::Stack< SharedPtr< U > > > &stackB)
Compares stacks of pointers.
Definition: compare.h:333
static bool AbstractEqual(SCG::ICollection< T > *const collA, SCG::ICollection< T > *const collB)
Compares two collections of unknown type.
Definition: compare.h:475
static bool AreEqual(const SharedPtr< SCG::Dictionary< K1, U1 > > &dictA, const SharedPtr< SCG::Dictionary< K2, U2 > > &dictB)
Compares dictionaries of different types.
Definition: compare.h:236
static bool AreEqual(const System::SharedPtr< SCG::IEnumerable< T > > &et, const System::SharedPtr< SCG::IEnumerable< U > > &eu)
Compares IEnumerable instances.
Definition: compare.h:449
static bool AreEqual(const SharedPtr< SCG::List< SharedPtr< T > > > &list, const System::ArrayPtr< SharedPtr< U > > &arr)
Compares lists with arrays in pointers elements case.
Definition: compare.h:185
static bool AreEqual(const SharedPtr< SCG::Dictionary< K, SharedPtr< U > > > &dictA, const SharedPtr< SCG::Dictionary< K, SharedPtr< U > > > &dictB)
Compares dictionaries of pointer mapped types.
Definition: compare.h:216