Skip to content

Commit 00acaab

Browse files
committed
Add xtd::tunit::constraints DSL
1 parent 1fb3f90 commit 00acaab

36 files changed

+552
-0
lines changed

src/xtd.core/include/xtd/implicit_using_namespaces.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ __using_namespace__(xtd::forms);
3131

3232
#if __XTD_CURRENT_TARGET_ID__ == __XTD_TARGET_ID_TEST_APPLICATION__
3333
__using_namespace__(xtd::tunit);
34+
__using_namespace__(xtd::tunit::constraints);
3435
#endif
3536

3637
#undef __using_namespace__

src/xtd.tunit/CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,38 @@ include("../../scripts/cmake/xtd_version.cmake")
77
add_include_directories("include")
88
add_references(xtd.core)
99
add_sources(
10+
"include/xtd/tunit/constraints/actual_value.hpp"
11+
"include/xtd/tunit/constraints/actual_value"
12+
"include/xtd/tunit/constraints/and_operator_value.hpp"
13+
"include/xtd/tunit/constraints/and_operator_value"
14+
"include/xtd/tunit/constraints/assert_that.hpp"
15+
"include/xtd/tunit/constraints/assert_that"
16+
"include/xtd/tunit/constraints/assert_type.hpp"
17+
"include/xtd/tunit/constraints/assert_type"
18+
"include/xtd/tunit/constraints/assert_value.hpp"
19+
"include/xtd/tunit/constraints/assert_value"
20+
"include/xtd/tunit/constraints/assert.hpp"
21+
"include/xtd/tunit/constraints/assert"
22+
"include/xtd/tunit/constraints/assume_that.hpp"
23+
"include/xtd/tunit/constraints/assume_that"
24+
"include/xtd/tunit/constraints/assume.hpp"
25+
"include/xtd/tunit/constraints/assume"
26+
"include/xtd/tunit/constraints/does_not_value.hpp"
27+
"include/xtd/tunit/constraints/does_not_value"
28+
"include/xtd/tunit/constraints/does_value.hpp"
29+
"include/xtd/tunit/constraints/does_value"
30+
"include/xtd/tunit/constraints/is_not_value.hpp"
31+
"include/xtd/tunit/constraints/is_not_value"
32+
"include/xtd/tunit/constraints/is_value.hpp"
33+
"include/xtd/tunit/constraints/is_value"
34+
"include/xtd/tunit/constraints/operator_value.hpp"
35+
"include/xtd/tunit/constraints/operator_value"
36+
"include/xtd/tunit/constraints/that_value.hpp"
37+
"include/xtd/tunit/constraints/that_value"
38+
"include/xtd/tunit/constraints/valid_that.hpp"
39+
"include/xtd/tunit/constraints/valid_that"
40+
"include/xtd/tunit/constraints/valid.hpp"
41+
"include/xtd/tunit/constraints/valid"
1042
"include/xtd/tunit/__default_insert_basic_ostream_operator.hpp"
1143
"include/xtd/tunit/__google_test_markers.hpp"
1244
"include/xtd/tunit/__tunit_join__items.hpp"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#pragma once
2+
#include <xtd/tunit/constraints/actual_value.hpp>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/// @file
2+
/// @brief Contains xtd::tunit::constraints::actual_value class.
3+
/// @copyright Copyright (c) 2025 Gammasoft. All rights reserved.
4+
#pragma once
5+
#include "assert_type.hpp"
6+
7+
/// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
8+
namespace xtd {
9+
/// @brief The tunit namespace contains a unit test library.
10+
namespace tunit {
11+
namespace constraints {
12+
template<class actual_t>
13+
class actual_value {
14+
public:
15+
actual_value() {}
16+
actual_value(actual_value&&) = default;
17+
actual_value(const actual_value&) = default;
18+
19+
xtd::tunit::constraints::assert_type assert_type() const noexcept {return assert_type_;};
20+
actual_value& type(xtd::tunit::constraints::assert_type assert_type) noexcept {
21+
assert_type_ = assert_type;
22+
return self_;
23+
};
24+
25+
auto is_assert() const noexcept {return assert_type() == xtd::tunit::constraints::assert_type::assert;}
26+
auto is_valid() const noexcept {return assert_type() == xtd::tunit::constraints::assert_type::valid;}
27+
auto is_assume() const noexcept {return assert_type() == xtd::tunit::constraints::assert_type::assume;}
28+
29+
const actual_t& actual() const noexcept {return *actual_;}
30+
actual_value& actual(const actual_t& actual) noexcept {
31+
actual_ = &actual;
32+
return self_;
33+
}
34+
35+
private:
36+
xtd::tunit::constraints::assert_type assert_type_;
37+
const actual_t* actual_ = null;
38+
};
39+
}
40+
}
41+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#pragma once
2+
#include <xtd/tunit/constraints/and_operator_value.hpp>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// @file
2+
/// @brief Contains xtd::tunit::constraints::and_operator_value class.
3+
/// @copyright Copyright (c) 2025 Gammasoft. All rights reserved.
4+
#pragma once
5+
#include "that_value.hpp"
6+
7+
/// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
8+
namespace xtd {
9+
/// @brief The tunit namespace contains a unit test library.
10+
namespace tunit {
11+
namespace constraints {
12+
template<class actual_t>
13+
class and_operator_value : public that_value<actual_t> {
14+
public:
15+
and_operator_value() = default;
16+
and_operator_value(that_value<actual_t>&& v) : that_value<actual_t> {std::move (v)} {}
17+
and_operator_value(const that_value<actual_t>& v) : that_value<actual_t> {v} {}
18+
};
19+
}
20+
}
21+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#pragma once
2+
#include <xtd/tunit/constraints/assert.hpp>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/// @file
2+
/// @brief Contains xtd::tunit::constraints::assert method.
3+
/// @copyright Copyright (c) 2025 Gammasoft. All rights reserved.
4+
#pragma once
5+
#include "actual_value.hpp"
6+
#include "and_operator_value.hpp"
7+
#include "assert_value.hpp"
8+
#include "does_not_value.hpp"
9+
#include "does_value.hpp"
10+
#include "is_not_value.hpp"
11+
#include "is_value.hpp"
12+
#include "operator_value.hpp"
13+
#include "that_value.hpp"
14+
15+
#include "operator_value_.hpp"
16+
17+
/// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
18+
namespace xtd {
19+
/// @brief The tunit namespace contains a unit test library.
20+
namespace tunit {
21+
namespace constraints {
22+
inline auto assert() {return xtd::tunit::constraints::assert_value(constraints::assert_type::assert);}
23+
}
24+
}
25+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#pragma once
2+
#include <xtd/tunit/constraints/assert_that.hpp>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// @file
2+
/// @brief Contains xtd::tunit::constraints::assert_that method.
3+
/// @copyright Copyright (c) 2025 Gammasoft. All rights reserved.
4+
#pragma once
5+
#include "assert.hpp"
6+
7+
/// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
8+
namespace xtd {
9+
/// @brief The tunit namespace contains a unit test library.
10+
namespace tunit {
11+
namespace constraints {
12+
template<class actual_t>
13+
inline auto assert_that(const actual_t& actual) {return xtd::tunit::constraints::assert().that(actual);}
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)