Skip to content

Commit

Permalink
New
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Nov 27, 2024
1 parent b7fe2a7 commit 68548af
Show file tree
Hide file tree
Showing 2 changed files with 208 additions and 0 deletions.
105 changes: 105 additions & 0 deletions src/test/pq/parameter_type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright (c) 2023-2024 Daniel Frey and Dr. Colin Hirsch
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)

#include <array>
#include <list>
#include <optional>
#include <set>
#include <span>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>
#include <vector>

#include <tao/pq.hpp>

static_assert( !tao::pq::parameter_type< void > );

static_assert( tao::pq::parameter_type< decltype( tao::pq::null ) > );

static_assert( tao::pq::parameter_type< bool > );

static_assert( tao::pq::parameter_type< char > );
static_assert( tao::pq::parameter_type< signed char > );
static_assert( tao::pq::parameter_type< unsigned char > );

static_assert( tao::pq::parameter_type< short > );
static_assert( tao::pq::parameter_type< unsigned short > );
static_assert( tao::pq::parameter_type< int > );
static_assert( tao::pq::parameter_type< unsigned > );
static_assert( tao::pq::parameter_type< long > );
static_assert( tao::pq::parameter_type< unsigned long > );
static_assert( tao::pq::parameter_type< long long > );
static_assert( tao::pq::parameter_type< unsigned long long > );

static_assert( tao::pq::parameter_type< float > );
static_assert( tao::pq::parameter_type< double > );
static_assert( tao::pq::parameter_type< long double > );

static_assert( tao::pq::parameter_type< const char* > );
static_assert( tao::pq::parameter_type< std::string > );
static_assert( tao::pq::parameter_type< std::string_view > );

static_assert( tao::pq::parameter_type< tao::pq::binary > );
static_assert( tao::pq::parameter_type< tao::pq::binary_view > );

static_assert( tao::pq::parameter_type< std::span< std::byte > > );
static_assert( tao::pq::parameter_type< std::span< std::byte, 42 > > );
static_assert( tao::pq::parameter_type< std::span< const std::byte > > );
static_assert( tao::pq::parameter_type< std::span< const std::byte, 42 > > );
static_assert( tao::pq::parameter_type< std::vector< std::byte > > );

// optional
static_assert( tao::pq::parameter_type< std::optional< int > > );
static_assert( tao::pq::parameter_type< std::optional< std::string > > );

// pair
static_assert( tao::pq::parameter_type< std::pair< bool, int > > );
static_assert( tao::pq::parameter_type< std::pair< std::string, tao::pq::binary > > );

// tuple
static_assert( tao::pq::parameter_type< std::tuple< bool, int, float > > );
static_assert( tao::pq::parameter_type< std::tuple< std::string, tao::pq::binary, unsigned > > );

// array
static_assert( tao::pq::parameter_type< std::array< int, 42 > > );
static_assert( tao::pq::parameter_type< std::array< std::string, 42 > > );
static_assert( tao::pq::parameter_type< std::list< std::string_view > > );
static_assert( tao::pq::parameter_type< std::set< double > > );
static_assert( tao::pq::parameter_type< std::unordered_set< char > > );

// note: vector<T> except for T == std::byte are registered as arrays by default
static_assert( tao::pq::parameter_type< std::vector< bool > > );
static_assert( tao::pq::parameter_type< std::vector< unsigned long long > > );

// aggregate
namespace example
{
struct user
{
std::string name;
int age;
std::string planet;
};

struct user2
{
std::string name;
int age;
std::string planet;
};

} // namespace example

template<>
inline constexpr bool tao::pq::is_aggregate< example::user > = true;

static_assert( tao::pq::parameter_type< example::user > );
static_assert( !tao::pq::parameter_type< example::user2 > ); // not registered

auto main() -> int
{
return 0;
}
103 changes: 103 additions & 0 deletions src/test/pq/result_type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Copyright (c) 2023-2024 Daniel Frey and Dr. Colin Hirsch
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)

#include <array>
#include <list>
#include <optional>
#include <set>
#include <span>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>
#include <vector>

#include <tao/pq.hpp>

static_assert( !tao::pq::result_type< void > );

static_assert( tao::pq::result_type< bool > );

static_assert( tao::pq::result_type< char > );
static_assert( tao::pq::result_type< signed char > );
static_assert( tao::pq::result_type< unsigned char > );

static_assert( tao::pq::result_type< short > );
static_assert( tao::pq::result_type< unsigned short > );
static_assert( tao::pq::result_type< int > );
static_assert( tao::pq::result_type< unsigned > );
static_assert( tao::pq::result_type< long > );
static_assert( tao::pq::result_type< unsigned long > );
static_assert( tao::pq::result_type< long long > );
static_assert( tao::pq::result_type< unsigned long long > );

static_assert( tao::pq::result_type< float > );
static_assert( tao::pq::result_type< double > );
static_assert( tao::pq::result_type< long double > );

static_assert( tao::pq::result_type< const char* > );
static_assert( tao::pq::result_type< std::string > );
static_assert( tao::pq::result_type< std::string_view > );

static_assert( tao::pq::result_type< tao::pq::binary > );
static_assert( !tao::pq::result_type< tao::pq::binary_view > );

static_assert( !tao::pq::result_type< std::span< std::byte > > );
static_assert( !tao::pq::result_type< std::span< std::byte, 42 > > );
static_assert( !tao::pq::result_type< std::span< const std::byte > > );
static_assert( !tao::pq::result_type< std::span< const std::byte, 42 > > );
static_assert( tao::pq::result_type< std::vector< std::byte > > );

// optional
static_assert( tao::pq::result_type< std::optional< int > > );
static_assert( tao::pq::result_type< std::optional< std::string > > );

// pair
static_assert( tao::pq::result_type< std::pair< bool, int > > );
static_assert( tao::pq::result_type< std::pair< std::string, tao::pq::binary > > );

// tuple
static_assert( tao::pq::result_type< std::tuple< bool, int, float > > );
static_assert( tao::pq::result_type< std::tuple< std::string, tao::pq::binary, unsigned > > );

// array
static_assert( !tao::pq::result_type< std::array< int, 42 > > );
static_assert( !tao::pq::result_type< std::array< std::string, 42 > > );
static_assert( tao::pq::result_type< std::list< std::string_view > > );
static_assert( tao::pq::result_type< std::set< double > > );
static_assert( tao::pq::result_type< std::unordered_set< char > > );

// note: vector<T> except for T == std::byte are registered as arrays by default
static_assert( tao::pq::result_type< std::vector< bool > > );
static_assert( tao::pq::result_type< std::vector< unsigned long long > > );

// aggregate
namespace example
{
struct user
{
std::string name;
int age;
std::string planet;
};

struct user2
{
std::string name;
int age;
std::string planet;
};

} // namespace example

template<>
inline constexpr bool tao::pq::is_aggregate< example::user > = true;

static_assert( tao::pq::result_type< example::user > );
static_assert( !tao::pq::result_type< example::user2 > ); // not registered

auto main() -> int
{
return 0;
}

0 comments on commit 68548af

Please sign in to comment.