xtd 0.2.0
Loading...
Searching...
No Matches
is_value.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "is_not_value.hpp"
6#include "operator_value.hpp"
7#include "../assert.hpp"
8#include "../assume.hpp"
12#include "../string_assert.hpp"
13#include "../string_assume.hpp"
14#include "../string_valid.hpp"
15#include "../valid.hpp"
16
18namespace xtd {
20 namespace tunit {
22 namespace constraints {
24 template<class actual_t> class that_value;
26
27 template<class actual_t>
28 class is_value : public actual_value<actual_t> {
29 public:
31
33 inline auto not_() {return is_not_value<actual_t>(self_);}
34
46 if (actual_value<actual_t>::is_assert()) xtd::tunit::assert::is_empty(actual_value<actual_t>::actual(), stack_frame);
47 else if (actual_value<actual_t>::is_valid()) xtd::tunit::valid::is_empty(actual_value<actual_t>::actual(), stack_frame);
48 else xtd::tunit::assume::is_empty(actual_value<actual_t>::actual(), stack_frame);
50 }
51
63 if (actual_value<actual_t>::is_assert()) xtd::tunit::assert::is_empty(actual_value<actual_t>::actual(), stack_frame);
64 else if (actual_value<actual_t>::is_valid()) xtd::tunit::valid::is_empty(actual_value<actual_t>::actual(), stack_frame);
65 else xtd::tunit::assume::is_empty(actual_value<actual_t>::actual(), stack_frame);
67 }
68
79 template<class expected_t>
80 auto equal_to(const expected_t& expected, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) const {
81 if (actual_value<actual_t>::is_assert()) xtd::tunit::assert::are_equal(expected, actual_value<actual_t>::actual(), stack_frame);
82 else if (actual_value<actual_t>::is_valid()) xtd::tunit::valid::are_equal(expected, actual_value<actual_t>::actual(), stack_frame);
83 else xtd::tunit::assume::are_equal(expected, actual_value<actual_t>::actual(), stack_frame);
85 }
86
97 template<class expected_t>
98 auto equal_to(const expected_t& expected, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) const {
99 if (actual_value<actual_t>::is_assert()) xtd::tunit::assert::are_equal(expected, actual_value<actual_t>::actual(), message, stack_frame);
100 else if (actual_value<actual_t>::is_valid()) xtd::tunit::valid::are_equal(expected, actual_value<actual_t>::actual(), message, stack_frame);
101 else xtd::tunit::assume::are_equal(expected, actual_value<actual_t>::actual(), message, stack_frame);
103 }
104
117 template<class expected_t>
118 auto same_as(const expected_t& expected, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) const {
119 if (actual_value<actual_t>::is_assert()) xtd::tunit::assert::are_same(expected, actual_value<actual_t>::actual(), stack_frame);
120 else if (actual_value<actual_t>::is_valid()) xtd::tunit::valid::are_same(expected, actual_value<actual_t>::actual(), stack_frame);
121 else xtd::tunit::assume::are_same(expected, actual_value<actual_t>::actual(), stack_frame);
123 }
124
137 template<class expected_t>
138 auto same_as(const expected_t& expected, const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) const {
139 if (actual_value<actual_t>::is_assert()) xtd::tunit::assert::are_same(expected, actual_value<actual_t>::actual(), message, stack_frame);
140 else if (actual_value<actual_t>::is_valid()) xtd::tunit::valid::are_same(expected, actual_value<actual_t>::actual(), message, stack_frame);
141 else xtd::tunit::assume::are_same(expected, actual_value<actual_t>::actual(), message, stack_frame);
143 }
144
145
146 protected:
148
150 is_value() = default;
151 is_value(actual_value<actual_t>&& v) : actual_value<actual_t> {std::move(v)} {}
152 is_value(const actual_value<actual_t>& v) : actual_value<actual_t> {v} {}
154
155 private:
156 template<class value_t> friend class that_value;
157 };
158 }
159 }
160}
Contains xtd::tunit::assume class.
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.hpp:48
static stack_frame current(const xtd::diagnostics::source_location &value=xtd::diagnostics::source_location::current()) noexcept
Crates a new xtd::diagnostics::stack_frame object corresponding to the location of the call site.
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 assert.hpp:351
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 two type are equal.
Definition assert.hpp:50
static void are_same(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that two objects do refer to differents objects.
Definition assert.hpp:246
static void are_same(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Assumes that two objects do refer to differents objects.
Definition assume.hpp:248
static void are_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Assumes that two type are equal.
Definition assume.hpp:41
static void is_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Assumes that collection contains an item.
Definition assume.hpp:360
Definition actual_value.hpp:18
Definition is_not_value.hpp:27
Definition is_value.hpp:28
auto same_as(const expected_t &expected, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) const
Asserts that value is same as specified expected.
Definition is_value.hpp:118
auto equal_to(const expected_t &expected, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) const
Asserts that value is equal to specified expected.
Definition is_value.hpp:80
auto empty(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that value is empty.
Definition is_value.hpp:45
auto empty(const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Asserts that value is empty and specified user message.
Definition is_value.hpp:62
auto equal_to(const expected_t &expected, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) const
Asserts that value is equal to specified expected with specified user message.
Definition is_value.hpp:98
auto same_as(const expected_t &expected, const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current()) const
Asserts that value is same as specified expected with specified user message.
Definition is_value.hpp:138
Definition operator_value.hpp:21
Definition that_value.hpp:21
static void are_same(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Validates that two objects do refer to different objects.
Definition valid.hpp:235
static void are_equal(const expected_t &expected, const actual_t &actual, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Validates that two type are equal.
Definition valid.hpp:41
static void is_empty(const value_t &value, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Validates that collection contains an item.
Definition valid.hpp:342
Contains xtd::tunit::collection_assert class.
Contains xtd::tunit::collection_assume class.
Contains xtd::tunit::collection_valid class.
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
@ v
The V key.
Definition console_key.hpp:130
Contains xtd::tunit::constraints::is_not_value class.
The constraints namespace contains the constraint-based assert model.
Definition actual_value.hpp:12
The tunit namespace contains a unit test library.
Definition abort_error.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::tunit::constraints::operator_value class.
Contains xtd::tunit::string_assert class.
Contains xtd::tunit::string_assume class.
Contains xtd::tunit::string_valid class.
Contains xtd::tunit::valid class.
Contains xtd::tunit::assert class.