xtd 0.2.0
base_assert.h
Go to the documentation of this file.
1 #pragma once
5 #include "../tunit_export.h"
6 #define __XTD_TUNIT_INTERNAL__
7 #include "__default_insert_basic_ostream_operator.h"
8 #include "__tunit_join__items.h"
9 #define __XTD_TUNIT_INTERNAL__
10 #include "abort_error.h"
11 #include "assert_error.h"
12 #include "ignore_error.h"
13 #include <xtd/environment>
14 #include <xtd/types>
15 #include <xtd/typeof>
16 #include <xtd/ustring>
17 #include <xtd/diagnostics/stack_frame>
18 
20 namespace xtd {
22  namespace tunit {
29  class tunit_export_ base_assert {
30  public:
32  base_assert() = delete;
34 
36 
43  static void abort();
51  static void abort(const xtd::diagnostics::stack_frame& stack_frame);
58  static void abort(const xtd::ustring& message);
59 
67  static void abort(const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
68 
75  static void fail();
83  static void fail(const xtd::diagnostics::stack_frame& stack_frame);
91  static void fail(const xtd::ustring& message);
100  static void fail(const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
101 
107  static void ignore();
115  static void ignore(const xtd::diagnostics::stack_frame& stack_frame);
122  static void ignore(const xtd::ustring& message);
130  static void ignore(const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
131 
137  static void succeed();
144  static void succeed(const xtd::diagnostics::stack_frame& stack_frame);
151  static void succeed(const xtd::ustring& message);
159  static void succeed(const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
161 
162  protected:
164 
172  static void error();
179  static void error(const xtd::ustring& message);
186  static void error(const xtd::ustring& actual, const xtd::ustring& expected, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
187 
194  static void fail(const xtd::ustring& actual, const xtd::ustring& expected, const xtd::ustring& message, const xtd::diagnostics::stack_frame& stack_frame);
195 
199  template <typename value_t>
200  static xtd::ustring to_string(const value_t& value) {return __tunit_to_string(value);}
204  template <typename value_t>
205  static xtd::ustring to_string(const value_t* value) {return __tunit_to_string(value);}
206 
210  template<typename collection_t>
211  static xtd::ustring join_items(const collection_t& collection) {return __tunit_join__items(collection);}
215  static xtd::ustring join_items(const xtd::ustring& str);
217 
218  private:
219  static bool is_debug() noexcept {return environment::compiler_version().build_type() == build_type::debug;}
220  };
221  }
222 }
The base class for assert.
Definition: base_assert.h:29
static xtd::ustring to_string(const value_t &value)
Convert specified value to xtd::ustring.
Definition: base_assert.h:200
Contains xtd::tunit::assert_error exception.
Contains xtd::tunit::ignore_error exception.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
Build type debug.
static xtd::ustring join_items(const collection_t &collection)
Join specified collection into xtd::ustring.
Definition: base_assert.h:211
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition: stack_frame.h:37
static xtd::compiler compiler_version() noexcept
Gets an xtd::compiler object that contains the current compiler identifier and version number...
Definition: environment.h:358
static xtd::ustring to_string(const value_t *value)
Convert specified value to xtd::ustring.
Definition: base_assert.h:205
xtd::build_type build_type() const noexcept
Gets the build type.
Contains xtd::tunit::abort_error exception.