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>
40 template <
typename T,
typename U>
43 return AreEqualData(arrA, arrB);
51 template <
typename T,
typename U>
55 if ((
void*)arrA.GetObjectOrNull() == (
void*)arrB.GetObjectOrNull())
61 return AreEqualContainerOfObjects(arrA->data(), arrB->data());
71 template <
typename T,
typename U>
74 return AreEqualData(listA, listB);
82 template <
typename T,
typename U>
86 if ((
void*)listA.GetObjectOrNull() == (
void*)listB.GetObjectOrNull())
92 return AreEqualContainerOfObjects(listA->data(), listB->data());
102 template <
typename T,
typename U>
105 return AreEqualData(listA, arrB);
113 template <
typename T,
typename U>
116 return AreEqualData(arrA, listB);
124 template <
typename T,
typename U>
128 if ((
void*)arr.GetObjectOrNull() == (
void*)list.GetObjectOrNull())
134 return AreEqualContainerOfObjects(arr->data(), list->data());
142 template <
typename T,
typename U>
146 if ((
void*)list.GetObjectOrNull() == (
void*)arr.GetObjectOrNull())
152 return AreEqualContainerOfObjects(list->data(), arr->data());
162 template <
typename K,
typename U>
165 return AreEqualData(dictA, dictB);
173 template <
typename K,
typename U>
177 if ((
void*)dictA.GetObjectOrNull() == (
void*)dictB.GetObjectOrNull())
180 if (!dictA || !dictB)
183 return AreEqualMapOfObjects(dictA->data(), dictB->data());
193 template <
typename K1,
typename U1,
typename K2,
typename U2>
196 ASPOSE_UNUSED(dictA);
197 ASPOSE_UNUSED(dictB);
208 template <
typename T,
typename U>
211 if ((
void*)containerPtrA.GetObjectOrNull() == (
void*)containerPtrB.GetObjectOrNull())
214 if (!containerPtrA || !containerPtrB)
217 if (containerPtrA->data().size() != containerPtrB->data().size())
220 return std::equal(containerPtrA->data().begin(), containerPtrA->data().end(), containerPtrB->data().begin());
228 template <
typename T,
typename U>
232 if ((
void*)contA.GetObjectOrNull() == (
void*)contB.GetObjectOrNull())
235 if (!contA || !contB)
238 return AreEqualContainerOfObjects(contA->data(), contB->data());
248 template <
typename T,
typename U>
251 return AreEqualData(queueA, queueB);
259 template <
typename T,
typename U>
263 if ((
void*)queueA.GetObjectOrNull() == (
void*)queueB.GetObjectOrNull())
266 if (!queueA || !queueB)
269 return AreEqualContainerOfObjects(queueA->data(), queueB->data());
279 template <
typename T,
typename U>
282 return AreEqualData(stackA, stackB);
290 template <
typename T,
typename U>
294 if ((
void*)stackA.GetObjectOrNull() == (
void*)stackB.GetObjectOrNull())
297 if (!stackA || !stackB)
300 return AreEqualContainerOfObjects(stackA->data(), stackB->data());
310 template <
typename K,
typename U>
313 return AreEqualData(dictA, dictB);
321 template <
typename K,
typename U>
325 if ((
void*)dictA.GetObjectOrNull() == (
void*)dictB.GetObjectOrNull())
328 if (!dictA || !dictB)
331 return AreEqualMapOfObjects(dictA->data(), dictB->data());
341 template <
typename K1,
typename U1,
typename K2,
typename U2>
354 template <
typename K,
typename U>
357 return AreEqualData(dictA, dictB);
365 template <
typename K,
typename U>
369 if ((
void*)dictA.GetObjectOrNull() == (
void*)dictB.GetObjectOrNull())
372 if (!dictA || !dictB)
375 return AreEqualMapOfObjects(dictA->data(), dictB->data());
385 template <
typename K1,
typename U1,
typename K2,
typename U2>
398 return AreEqualData(arrA, arrB);
406 template <
typename T,
typename U>
409 auto tenum = et->GetEnumerator();
410 auto uenum = eu->GetEnumerator();
412 while (tenum->MoveNext())
414 if (!uenum->MoveNext())
418 if (!AreEqualObjects(tenum->get_Current(), uenum->get_Current()))
423 return !uenum->MoveNext();
432 template <
typename T>
440 if (!collA || !collB)
452 while (enA->MoveNext() && enB->MoveNext())
454 auto&& itA = enA->get_Current();
455 auto&& itB = enB->get_Current();
470 template <
typename T>
471 static bool AreEqualData(
const SharedPtr<T>& containerPtrA,
474 if (containerPtrA == containerPtrB)
477 if (!containerPtrA || !containerPtrB)
480 return containerPtrA->data() == containerPtrB->data();
488 template <
typename T,
typename U>
489 static bool AreEqualData(
const SharedPtr<T>& containerPtrA,
490 const SharedPtr<U>& containerPtrB)
492 if ((
void*)containerPtrA.GetObjectOrNull() == (
void*)containerPtrB.GetObjectOrNull())
495 if (!containerPtrA || !containerPtrB)
498 if (containerPtrA->data().size() != containerPtrB->data().size())
501 return std::equal(containerPtrA->data().begin(), containerPtrA->data().end(), containerPtrB->data().begin());
511 template <
typename T,
typename U>
512 static bool AreEqualObjects(
const T& ptrA,
const U& ptrB)
522 template <
typename K,
typename V>
523 static bool AreEqualObjectPairs(
const std::pair<K, V>& pairA,
const std::pair<K, V>& pairB)
533 template <
typename Tvect,
typename Uvect>
534 static bool AreEqualContainerOfObjects(Tvect& contA, Uvect& contB)
536 if (contA.size() != contB.size())
539 return std::equal(contA.begin(), contA.end(), contB.begin(),
540 TestCompare::AreEqualObjects<typename Tvect::value_type, typename Uvect::value_type>);
547 template <
typename Tmap>
548 static bool AreEqualMapOfObjects(
const Tmap& mapA,
const Tmap& mapB)
550 if (mapA.size() != mapB.size())
555 return std::equal(mapA.begin(), mapA.end(), mapB.begin(),
556 TestCompare::AreEqualObjectPairs<Tmap::key_type, Tmap::mapped_type>);
560 for (
typename Tmap::const_iterator itA = mapA.begin(); itA != mapA.end(); ++itA)
562 typename Tmap::const_iterator itF = mapB.find(itA->first);
563 if (itF == mapB.end() || !itF->second->Equals(itA->second))
Class that represents an array data structure. Objects of this class should only be allocated using S...
Definition: array.h:259
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:25
virtual SharedPtr< IEnumerator< T > > GetEnumerator()=0
Gets enumerator.
List forward declaration.
Definition: list.h:127
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
Definition: algorithms.h:10
Definition: db_command.h:9
Template predicate that checks if boxing of the specified type is supported.
Definition: boxable_traits.h:16
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:41
static bool AreEqual(const SCG::QueuePtr< T > &queueA, const SCG::QueuePtr< U > &queueB)
Compares queues of non-pointers.
Definition: compare.h:249
static bool AreEqual(const SharedPtr< SCG::List< SharedPtr< T > > > &listA, const SharedPtr< SCG::List< SharedPtr< U > > > &listB)
Compares lists of pointers.
Definition: compare.h:83
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:366
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:386
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:114
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:355
static bool AreEqual(const System::Collections::Specialized::StringCollectionPtr &arrA, const System::Collections::Specialized::StringCollectionPtr &arrB)
Compares string collections.
Definition: compare.h:396
static bool AreEqual(const SCG::QueuePtr< SharedPtr< T > > &queueA, const SCG::QueuePtr< SharedPtr< U > > &queueB)
Compares queues of pointers.
Definition: compare.h:260
static bool AreEqual(const SharedPtr< SCG::List< T > > &listA, const SharedPtr< SCG::List< U > > &listB)
Compares lists of non-pointers.
Definition: compare.h:72
static bool AreEqual(const SharedPtr< SCG::HashSet< T > > &containerPtrA, const SharedPtr< SCG::HashSet< U > > &containerPtrB)
Compares hashsets of non-pointers.
Definition: compare.h:209
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:103
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:311
static bool AreEqual(const SharedPtr< Array< SharedPtr< T > > > &arrA, const SharedPtr< Array< SharedPtr< U > > > &arrB)
Compares arrays of pointers.
Definition: compare.h:52
static bool AreEqual(const SharedPtr< SCG::Stack< T > > &stackA, const SharedPtr< SCG::Stack< U > > &stackB)
Compares stacks of non-pointers.
Definition: compare.h:280
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:163
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:342
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:125
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:322
static bool AreEqual(const SharedPtr< SCG::HashSet< SharedPtr< T > > > &contA, const SharedPtr< SCG::HashSet< SharedPtr< U > > > &contB)
Compares hashsets of pointers.
Definition: compare.h:229
static bool AreEqual(const SharedPtr< SCG::Stack< SharedPtr< T > > > &stackA, const SharedPtr< SCG::Stack< SharedPtr< U > > > &stackB)
Compares stacks of pointers.
Definition: compare.h:291
static bool AbstractEqual(SCG::ICollection< T > *const collA, SCG::ICollection< T > *const collB)
Compares two collections of unknown type.
Definition: compare.h:433
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:194
static bool AreEqual(const System::SharedPtr< SCG::IEnumerable< T > > &et, const System::SharedPtr< SCG::IEnumerable< U > > &eu)
Compares IEnumerable instances.
Definition: compare.h:407
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:143
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:174