43 template<
typename expected_t,
typename collection_t>
56 template<
typename expected_t,
typename collection_t>
58 for (
auto item : collection)
59 if (
dynamic_cast<expected_t
>(item) ==
nullptr) {
60 fail(
"all items instance of <" + typeof_<expected_t>().full_name() +
">", join_items(collection), message, stack_frame);
63 assert::succeed(message, stack_frame);
67 template<
typename expected_t,
typename item_t>
69 template<
typename expected_t,
typename item_t>
71 for (
auto item : collection)
72 if (dynamic_cast<expected_t>(item) == nullptr) {
73 fail(
"all items instance of <" + typeof_<expected_t>().full_name() +
">", join_items(collection), message, stack_frame);
76 assert::succeed(message, stack_frame);
93 template<
typename collection_t>
108 template<
typename collection_t>
110 for (
auto item : collection)
111 if (item ==
nullptr) {
112 fail(
"all items are not null", join_items(collection), message, stack_frame);
115 assert::succeed(message, stack_frame);
119 template<
typename item_t>
121 template<
typename item_t>
123 for (
auto item : collection)
124 if (item == nullptr) {
125 fail(
"all items are not null", join_items(collection), message, stack_frame);
128 assert::succeed(message, stack_frame);
144 template<
typename collection_t>
158 template<
typename collection_t>
160 auto value = *collection.cbegin();
161 std::map<
decltype(value),
int32> counts;
162 for (
auto item : collection) {
163 auto result = counts.emplace(item, 1);
164 if (result.second ==
false)
165 fail(
"all items are unique", join_items(collection), message, stack_frame);
167 assert::succeed(message, stack_frame);
171 template<
typename item_t>
173 template<
typename item_t>
175 std::map<item_t, int32> counts;
176 for (
auto item : collection) {
177 auto result = counts.emplace(item, 1);
178 if (result.second ==
false)
179 fail(
"all items are unique", join_items(collection), message, stack_frame);
181 assert::succeed(message, stack_frame);
196 template<
typename expected_t,
typename actual_t>
209 template<
typename expected_t,
typename actual_t>
211 if (std::equal(actual.begin(), actual.end(), expected.begin(), expected.end()) ==
false)
212 fail(join_items(expected), join_items(actual), message, stack_frame);
214 assert::succeed(message, stack_frame);
218 template<
typename item_t>
220 template<
typename item_t>
222 if (std::equal(actual.begin(), actual.end(), expected.begin(), expected.end()) ==
false)
223 fail(join_items(expected), join_items(actual), message, stack_frame);
225 assert::succeed(message, stack_frame);
227 template<
typename collection_t,
typename item_t>
229 template<
typename collection_t,
typename item_t>
231 if (std::equal(actual.begin(), actual.end(), expected.begin(), expected.end()) ==
false)
232 fail(join_items(expected), join_items(actual), message, stack_frame);
234 assert::succeed(message, stack_frame);
236 template<
typename item_t,
typename collection_t>
238 template<
typename item_t,
typename collection_t>
240 if (std::equal(actual.begin(), actual.end(), expected.begin(), expected.end()) ==
false)
241 fail(join_items(expected), join_items(actual), message, stack_frame);
243 assert::succeed(message, stack_frame);
258 template<
typename expected_t,
typename actual_t>
271 template<
typename expected_t,
typename actual_t>
273 if (!__are_equivalent(expected, actual))
274 fail(
"equivalent " + join_items(expected), join_items(actual), message, stack_frame);
276 assert::succeed(message, stack_frame);
280 template<
typename expected_t,
typename actual_t>
282 template<
typename expected_t,
typename actual_t>
284 if (!__are_equivalent(expected, actual))
285 fail(
"equivalent " + join_items(expected), join_items(actual), message, stack_frame);
287 assert::succeed(message, stack_frame);
289 template<
typename collection_t,
typename item_t>
291 template<
typename collection_t,
typename item_t>
293 if (!__are_equivalent(expected, actual))
294 fail(
"equivalent " + join_items(expected), join_items(actual), message, stack_frame);
296 assert::succeed(message, stack_frame);
298 template<
typename item_t,
typename collection_t>
300 template<
typename item_t,
typename collection_t>
302 if (!__are_equivalent(expected, actual))
303 fail(
"equivalent " + join_items(expected), join_items(actual), message, stack_frame);
305 assert::succeed(message, stack_frame);
320 template<
typename expected_t,
typename actual_t>
333 template<
typename expected_t,
typename actual_t>
335 if (std::equal(actual.begin(), actual.end(), expected.begin(), expected.end()) ==
true)
336 fail(
"not " + join_items(expected), join_items(actual), message, stack_frame);
338 assert::succeed(message, stack_frame);
342 template<
typename item_t>
344 template<
typename item_t>
346 if (std::equal(actual.begin(), actual.end(), expected.begin(), expected.end()) ==
true)
347 fail(
"not " + join_items(expected), join_items(actual), message, stack_frame);
349 assert::succeed(message, stack_frame);
351 template<
typename collection_t,
typename item_t>
353 template<
typename collection_t,
typename item_t>
355 if (std::equal(actual.begin(), actual.end(), expected.begin(), expected.end()) ==
true)
356 fail(
"not " + join_items(expected), join_items(actual), message, stack_frame);
358 assert::succeed(message, stack_frame);
360 template<
typename item_t,
typename collection_t>
362 template<
typename item_t,
typename collection_t>
364 if (std::equal(actual.begin(), actual.end(), expected.begin(), expected.end()) ==
true)
365 fail(
"not " + join_items(expected), join_items(actual), message, stack_frame);
367 assert::succeed(message, stack_frame);
382 template<
typename expected_t,
typename actual_t>
395 template<
typename expected_t,
typename actual_t>
397 if (__are_equivalent(expected, actual))
398 fail(
"not equivalent " + join_items(expected), join_items(actual), message, stack_frame);
400 assert::succeed(message, stack_frame);
404 template<
typename expected_t,
typename actual_t>
406 template<
typename expected_t,
typename actual_t>
408 if (__are_equivalent(expected, actual))
409 fail(
"not equivalent " + join_items(expected), join_items(actual), message, stack_frame);
411 assert::succeed(message, stack_frame);
413 template<
typename collection_t,
typename item_t>
415 template<
typename collection_t,
typename item_t>
417 if (__are_equivalent(expected, actual))
418 fail(
"not equivalent " + join_items(expected), join_items(actual), message, stack_frame);
420 assert::succeed(message, stack_frame);
422 template<
typename item_t,
typename collection_t>
424 template<
typename item_t,
typename collection_t>
426 if (__are_equivalent(expected, actual))
427 fail(
"not equivalent " + join_items(expected), join_items(actual), message, stack_frame);
429 assert::succeed(message, stack_frame);
444 template<
typename expected_t,
typename actual_t>
457 template<
typename expected_t,
typename actual_t>
459 for (
const auto& item : expected) {
460 if (std::find_if(std::begin(actual), std::end(actual), [&](
const auto& value) {
return value == item;}) == std::end(actual)) {
461 fail(
"contains " + join_items(expected), join_items(actual), message, stack_frame);
465 assert::succeed(message, stack_frame);
469 template<
typename item_t>
471 template<
typename item_t>
473 for (
const auto& item : expected) {
474 if (std::find_if(std::begin(actual), std::end(actual), [&](
const item_t& value) {
return value == item;}) == std::end(actual)) {
475 fail(
"contains " + join_items(expected), join_items(actual), message, stack_frame);
479 assert::succeed(message, stack_frame);
481 template<
typename collection_t,
typename item_t>
483 template<
typename collection_t,
typename item_t>
485 for (
const auto& item : expected) {
486 if (std::find_if(std::begin(actual), std::end(actual), [&](
const item_t& value) {
return value == item;}) == std::end(actual)) {
487 fail(
"contains " + join_items(expected), join_items(actual), message, stack_frame);
491 assert::succeed(message, stack_frame);
493 template<
typename item_t,
typename collection_t>
495 template<
typename item_t,
typename collection_t>
497 for (
const auto& item : expected) {
498 if (std::find_if(std::begin(actual), std::end(actual), [&](
const item_t& value) {
return value == item;}) == std::end(actual)) {
499 fail(
"contains " + join_items(expected), join_items(actual), message, stack_frame);
503 assert::succeed(message, stack_frame);
518 template<
typename expected_t,
typename actual_t>
531 template<
typename expected_t,
typename actual_t>
533 for (
const auto& item : expected) {
534 if (std::find_if(std::begin(actual), std::end(actual), [&](
const auto& value) {
return value == item;}) == std::end(actual)) {
535 assert::succeed(message, stack_frame);
539 fail(
"not contains " + join_items(expected), join_items(actual), message, stack_frame);
543 template<
typename item_t>
545 template<
typename item_t>
547 for (
const auto& item : expected) {
548 if (std::find_if(std::begin(actual), std::end(actual), [&](
const item_t& value) {
return value == item;}) == std::end(actual)) {
549 assert::succeed(message, stack_frame);
553 fail(
"not contains " + join_items(expected), join_items(actual), message, stack_frame);
555 template<
typename collection_t,
typename item_t>
557 template<
typename collection_t,
typename item_t>
559 for (
const auto& item : expected) {
560 if (std::find_if(std::begin(actual), std::end(actual), [&](
const item_t& value) {
return value == item;}) == std::end(actual)) {
561 assert::succeed(message, stack_frame);
565 fail(
"not contains " + join_items(expected), join_items(actual), message, stack_frame);
567 template<
typename item_t,
typename collection_t>
569 template<
typename item_t,
typename collection_t>
571 for (
const auto& item : expected) {
572 if (std::find_if(std::begin(actual), std::end(actual), [&](
const item_t& value) {
return value == item;}) == std::end(actual)) {
573 assert::succeed(message, stack_frame);
577 fail(
"not contains " + join_items(expected), join_items(actual), message, stack_frame);
592 template<
typename value_t>
606 template<
typename value_t>
608 if (std::empty(value))
609 assert::succeed(message, stack_frame);
611 fail(
"<empty>", join_items(value), message, stack_frame);
615 template<
typename value_t>
617 template<
typename value_t>
619 if (std::empty(value))
620 assert::succeed(message, stack_frame);
622 fail(
"<empty>", join_items(value), message, stack_frame);
637 template<
typename value_t>
651 template<
typename value_t>
653 if (!std::empty(value))
654 assert::succeed(message, stack_frame);
656 fail(
"not <empty>",
"<empty>", message, stack_frame);
660 template<
typename value_t>
662 template<
typename value_t>
664 if (!std::empty(value))
665 assert::succeed(message, stack_frame);
667 fail(
"not <empty>",
"<empty>", message, stack_frame);
682 template<
typename value_t>
696 template<
typename value_t>
698 if (std::is_sorted(value.begin(), value.end()))
699 assert::succeed(message, stack_frame);
701 fail(
"<ordered>", join_items(value), message, stack_frame);
705 template<
typename value_t>
707 template<
typename value_t>
709 if (std::is_sorted(value.begin(), value.end()))
710 assert::succeed(message, stack_frame);
712 fail(
"<ordered>", join_items(value), message, stack_frame);
718 template <
typename expected_t,
typename actual_t>
719 static bool __are_equivalent(
const expected_t expected,
const actual_t& actual) {
720 if (std::distance(expected.begin(), expected.end()) != std::distance(actual.begin(), actual.end()))
return false;
721 for (
auto iterator = expected.begin(); iterator != expected.end(); ++iterator)
722 if (std::find_if(std::begin(actual), std::end(actual), [&](
const auto& value) {
return value == *iterator;}) == std::end(actual))
return false;
static const basic_string empty_string
Represents the empty basic_string.
Definition basic_string.h:124
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.h:47
static stack_frame current(const xtd::source_location &value=xtd::source_location::current()) noexcept
Crates a new xtd::diagnostics::stack_frame object corresponding to the location of the call site.
The base class for assert.
Definition base_assert.h:29
The collection_assert class contains a collection of static methods that implement the most collectio...
Definition collection_assert.h:23
static void are_equivalent(const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are equivalent.
Definition collection_assert.h:272
static void is_ordered(const value_t &value, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection is ordered.
Definition collection_assert.h:697
static void is_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection contains an item.
Definition collection_assert.h:593
static void is_ordered(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection is ordered.
Definition collection_assert.h:683
static void are_equal(const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are equal.
Definition collection_assert.h:210
static void are_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are equal.
Definition collection_assert.h:197
static void are_not_equivalent(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are not equivalent.
Definition collection_assert.h:383
static void is_not_empty(const value_t &value, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection or traits does not contain any item.
Definition collection_assert.h:652
static void contains(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection contains all items.
Definition collection_assert.h:445
static void all_items_are_not_null(const collection_t &collection, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are not null.
Definition collection_assert.h:109
static void all_items_are_unique(const collection_t &collection, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are unique.
Definition collection_assert.h:159
static void all_items_are_instances_of(const collection_t &collection, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are of the type supplied or a derived type.
Definition collection_assert.h:57
static void are_not_equal(const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are not equal.
Definition collection_assert.h:334
static void does_not_contain(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection contains all items.
Definition collection_assert.h:519
static void is_empty(const value_t &value, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection contains an item.
Definition collection_assert.h:607
static void is_not_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection or traits does not contain any item.
Definition collection_assert.h:638
static void all_items_are_unique(const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are unique.
Definition collection_assert.h:145
static void all_items_are_not_null(const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are not null.
Definition collection_assert.h:94
static void does_not_contain(const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection contains all items.
Definition collection_assert.h:532
static void are_not_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are not equal.
Definition collection_assert.h:321
static void contains(const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that collection contains all items.
Definition collection_assert.h:458
static void are_not_equivalent(const expected_t &expected, const actual_t &actual, const std::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are not equivalent.
Definition collection_assert.h:396
static void all_items_are_instances_of(const collection_t &collection, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are of the type supplied or a derived type.
Definition collection_assert.h:44
static void are_equivalent(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that all collection items are equivalent.
Definition collection_assert.h:259
#define tunit_export_
Define shared library export.
Definition tunit_export.h:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::tunit::assert class.