mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-03-24 02:28:43 +00:00
Squashed 'externals/mp/' content from commit 29cb5588d
git-subtree-dir: externals/mp git-subtree-split: 29cb5588da3a18ed571a0e41622900a01b9f01eb
This commit is contained in:
12
tests/all_tests.cpp
Normal file
12
tests/all_tests.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#include "metavalue_tests.h"
|
||||
#include "traits_tests.h"
|
||||
#include "typelist_tests.h"
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
27
tests/metavalue_tests.h
Normal file
27
tests/metavalue_tests.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <mp/metavalue/lift_value.h>
|
||||
#include <mp/metavalue/value_cast.h>
|
||||
#include <mp/metavalue/value_equal.h>
|
||||
|
||||
using namespace mp;
|
||||
|
||||
// lift_value
|
||||
|
||||
static_assert(std::is_same_v<lift_value<3>, std::integral_constant<int, 3>>);
|
||||
static_assert(std::is_same_v<lift_value<false>, std::false_type>);
|
||||
|
||||
// value_cast
|
||||
|
||||
static_assert(std::is_same_v<value_cast<int, std::true_type>, std::integral_constant<int, 1>>);
|
||||
|
||||
// value_equal
|
||||
|
||||
static_assert(std::is_same_v<value_equal<std::true_type, std::integral_constant<int, 1>>, std::true_type>);
|
||||
42
tests/traits_tests.h
Normal file
42
tests/traits_tests.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
#include <mp/traits/function_info.h>
|
||||
#include <mp/traits/is_instance_of_template.h>
|
||||
|
||||
using namespace mp;
|
||||
|
||||
// function_info
|
||||
|
||||
struct Bar {
|
||||
int frob(double a) { return a; }
|
||||
};
|
||||
|
||||
static_assert(parameter_count_v<void()> == 0);
|
||||
static_assert(parameter_count_v<void(int, int, int)> == 3);
|
||||
static_assert(std::is_same_v<get_parameter<void(*)(bool, int, double), 2>, double>);
|
||||
static_assert(std::is_same_v<equivalent_function_type<void(*)(bool, int, double)>, void(bool, int, double)>);
|
||||
static_assert(std::is_same_v<return_type<void(*)(bool, int, double)>, void>);
|
||||
static_assert(std::is_same_v<equivalent_function_type<decltype(&Bar::frob)>, int(double)>);
|
||||
static_assert(std::is_same_v<class_type<decltype(&Bar::frob)>, Bar>);
|
||||
|
||||
// is_instance_of_template
|
||||
|
||||
template<class, class...>
|
||||
class Foo {};
|
||||
|
||||
template<class, class>
|
||||
class Pair {};
|
||||
|
||||
static_assert(is_instance_of_template_v<std::tuple, std::tuple<int, bool>>);
|
||||
static_assert(!is_instance_of_template_v<std::tuple, bool>);
|
||||
static_assert(is_instance_of_template_v<Foo, Foo<bool>>);
|
||||
static_assert(is_instance_of_template_v<Pair, Pair<bool, int>>);
|
||||
static_assert(!is_instance_of_template_v<Pair, Foo<bool, int>>);
|
||||
102
tests/typelist_tests.h
Normal file
102
tests/typelist_tests.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/* This file is part of the mp project.
|
||||
* Copyright (c) 2020 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <mp/typelist/append.h>
|
||||
#include <mp/typelist/cartesian_product.h>
|
||||
#include <mp/typelist/concat.h>
|
||||
#include <mp/typelist/contains.h>
|
||||
#include <mp/typelist/get.h>
|
||||
#include <mp/typelist/head.h>
|
||||
#include <mp/typelist/length.h>
|
||||
#include <mp/typelist/lift_sequence.h>
|
||||
#include <mp/typelist/list.h>
|
||||
#include <mp/typelist/lower_to_tuple.h>
|
||||
#include <mp/typelist/prepend.h>
|
||||
#include <mp/typelist/tail.h>
|
||||
|
||||
using namespace mp;
|
||||
|
||||
// append
|
||||
|
||||
static_assert(std::is_same_v<append<list<int, bool>, double>, list<int, bool, double>>);
|
||||
static_assert(std::is_same_v<append<list<>, int, int>, list<int, int>>);
|
||||
|
||||
// cartesian_product
|
||||
|
||||
static_assert(
|
||||
std::is_same_v<
|
||||
cartesian_product<list<int, bool>, list<double, float>, list<char, unsigned>>,
|
||||
list<
|
||||
list<int, double, char>,
|
||||
list<int, double, unsigned>,
|
||||
list<int, float, char>,
|
||||
list<int, float, unsigned>,
|
||||
list<bool, double, char>,
|
||||
list<bool, double, unsigned>,
|
||||
list<bool, float, char>,
|
||||
list<bool, float, unsigned>
|
||||
>
|
||||
>
|
||||
);
|
||||
|
||||
// concat
|
||||
|
||||
static_assert(std::is_same_v<concat<list<int, bool>, list<double>>, list<int, bool, double>>);
|
||||
static_assert(std::is_same_v<concat<list<>, list<int>, list<int>>, list<int, int>>);
|
||||
|
||||
// contains
|
||||
|
||||
static_assert(contains_v<list<int>, int>);
|
||||
static_assert(!contains_v<list<>, int>);
|
||||
static_assert(!contains_v<list<double>, int>);
|
||||
static_assert(contains_v<list<double, int>, int>);
|
||||
|
||||
// get
|
||||
|
||||
static_assert(std::is_same_v<get<0, list<int, double>>, int>);
|
||||
static_assert(std::is_same_v<get<1, list<int, double>>, double>);
|
||||
|
||||
// head
|
||||
|
||||
static_assert(std::is_same_v<head<list<int, double>>, int>);
|
||||
static_assert(std::is_same_v<head<list<int>>, int>);
|
||||
|
||||
// length
|
||||
|
||||
static_assert(length_v<list<>> == 0);
|
||||
static_assert(length_v<list<int>> == 1);
|
||||
static_assert(length_v<list<int, int, int>> == 3);
|
||||
|
||||
// lift_sequence
|
||||
|
||||
static_assert(
|
||||
std::is_same_v<
|
||||
lift_sequence<std::make_index_sequence<3>>,
|
||||
list<std::integral_constant<std::size_t, 0>, std::integral_constant<std::size_t, 1>, std::integral_constant<std::size_t, 2>>
|
||||
>
|
||||
);
|
||||
|
||||
// lower_to_tuple
|
||||
|
||||
static_assert(lower_to_tuple_v<list<std::integral_constant<std::size_t, 0>, std::integral_constant<std::size_t, 1>, std::integral_constant<std::size_t, 2>>> == std::tuple<std::size_t, std::size_t, std::size_t>(0, 1, 2));
|
||||
static_assert(lower_to_tuple_v<list<std::true_type, std::false_type>> == std::make_tuple(true, false));
|
||||
|
||||
// prepend
|
||||
|
||||
static_assert(std::is_same_v<prepend<list<int, int>, double>, list<double, int, int>>);
|
||||
static_assert(std::is_same_v<prepend<list<>, double>, list<double>>);
|
||||
static_assert(std::is_same_v<prepend<list<int>, double, bool>, list<double, bool, int>>);
|
||||
|
||||
// tail
|
||||
|
||||
static_assert(std::is_same_v<tail<list<int, double>>, list<double>>);
|
||||
static_assert(std::is_same_v<tail<list<int>>, list<>>);
|
||||
Reference in New Issue
Block a user