Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Slávik
Algorithms Library Toolkit Core
Commits
4432c30b
Commit
4432c30b
authored
Apr 24, 2022
by
Ing. Jan Trávníček
Browse files
abstraction: other base type abstraction tests
parent
50f2a9f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
alib2abstraction/test-src/core/type_util.cpp
View file @
4432c30b
...
...
@@ -5,6 +5,7 @@
#include
<alib/variant>
#include
<alib/set>
#include
<alib/vector>
#include
<object/ObjectFactory.h>
...
...
@@ -19,4 +20,40 @@ TEST_CASE ( "Compontents", "[unit][core]" ) {
ext
::
vector
<
core
::
type_details
>
data
;
data
.
push_back
(
core
::
type_details
::
get
<
ext
::
variant
<
int
,
char
>
>
(
)
);
}
SECTION
(
"type compatibility requirements"
)
{
auto
int_t
=
core
::
type_details
::
get
<
int
>
(
);
auto
univ_t
=
core
::
type_details
::
universal_type
(
);
REQUIRE
(
int_t
.
compatible_with
(
univ_t
)
);
REQUIRE
(
!
univ_t
.
compatible_with
(
int_t
)
);
auto
set_int
=
core
::
type_details
::
get
<
ext
::
set
<
int
>
>
(
);
std
::
vector
<
std
::
unique_ptr
<
core
::
type_details_base
>
>
subTypes
;
subTypes
.
push_back
(
std
::
make_unique
<
core
::
type_details_universal_type
>
(
)
);
auto
set_univ
=
std
::
make_unique
<
core
::
type_details_template
>
(
"ext::set"
,
std
::
move
(
subTypes
)
);
REQUIRE
(
static_cast
<
const
core
::
type_details_base
&
>
(
set_int
).
compatible_with
(
*
set_univ
)
);
REQUIRE
(
!
set_univ
->
compatible_with
(
set_int
)
);
std
::
vector
<
std
::
unique_ptr
<
core
::
type_details_base
>
>
subTypes2
;
subTypes2
.
push_back
(
std
::
make_unique
<
core
::
type_details_universal_type
>
(
)
);
auto
vec_univ
=
std
::
make_unique
<
core
::
type_details_template
>
(
"ext::vector"
,
std
::
move
(
subTypes2
)
);
std
::
vector
<
std
::
unique_ptr
<
core
::
type_details_base
>
>
subTypes3
;
subTypes3
.
push_back
(
std
::
move
(
vec_univ
)
);
auto
set_vec_univ
=
std
::
make_unique
<
core
::
type_details_template
>
(
"ext::set"
,
std
::
move
(
subTypes3
)
);
auto
set_unk
=
core
::
type_details
::
get
(
ext
::
set
<
int
>
{
}
);
REQUIRE
(
set_vec_univ
->
compatible_with
(
*
set_univ
)
);
REQUIRE
(
static_cast
<
const
core
::
type_details_base
&
>
(
set_unk
).
compatible_with
(
*
set_vec_univ
)
);
}
SECTION
(
"size_t"
)
{
auto
size_t_variant
=
core
::
type_details
::
get
<
size_t
>
(
);
auto
size_t_explicit
=
core
::
type_details
::
as_type
(
"size_t"
);
REQUIRE
(
size_t_variant
.
compatible_with
(
size_t_explicit
)
);
REQUIRE
(
size_t_explicit
.
compatible_with
(
size_t_variant
)
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment