File: detail_argument_traits_test.cpp

package info (click to toggle)
boost1.90 1.90.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 593,120 kB
  • sloc: cpp: 4,190,908; xml: 196,648; python: 34,618; ansic: 23,145; asm: 5,468; sh: 3,774; makefile: 1,161; perl: 1,020; sql: 728; ruby: 676; yacc: 478; java: 77; lisp: 24; csh: 6
file content (61 lines) | stat: -rw-r--r-- 2,027 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2019 Hans Dembinski
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/core/lightweight_test.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/histogram/detail/argument_traits.hpp>
#include <boost/histogram/sample.hpp>
#include <boost/histogram/weight.hpp>

namespace dtl = boost::histogram::detail;

int main() {
  using boost::histogram::sample;
  using boost::histogram::weight;

  // is_weight
  {
    struct A {};
    using B = int;
    BOOST_TEST_NOT(dtl::is_weight<A>::value);
    BOOST_TEST_NOT(dtl::is_weight<B>::value);
    BOOST_TEST_NOT(dtl::is_weight<decltype(sample(0))>::value);
    BOOST_TEST(dtl::is_weight<decltype(weight(0))>::value);
  }

  // is_sample
  {
    struct A {};
    using B = int;
    BOOST_TEST_NOT(dtl::is_sample<A>::value);
    BOOST_TEST_NOT(dtl::is_sample<B>::value);
    BOOST_TEST_NOT(dtl::is_sample<decltype(weight(0))>::value);
    BOOST_TEST(dtl::is_sample<decltype(sample(0))>::value);
    BOOST_TEST(dtl::is_sample<decltype(sample(0, A{}))>::value);
  }

  using T1 = dtl::argument_traits<int>;
  using E1 = dtl::argument_traits_holder<1, 0, -1, -1, std::tuple<>>;
  BOOST_TEST_TRAIT_SAME(T1, E1);

  using T2 = dtl::argument_traits<int, int>;
  using E2 = dtl::argument_traits_holder<2, 0, -1, -1, std::tuple<>>;
  BOOST_TEST_TRAIT_SAME(T2, E2);

  using T3 = dtl::argument_traits<decltype(weight(0)), int, int>;
  using E3 = dtl::argument_traits_holder<2, 1, 0, -1, std::tuple<>>;
  BOOST_TEST_TRAIT_SAME(T3, E3);

  using T4 = dtl::argument_traits<decltype(weight(0)), int, int, decltype(sample(0))>;
  using E4 = dtl::argument_traits_holder<2, 1, 0, 3, std::tuple<int>>;
  BOOST_TEST_TRAIT_SAME(T4, E4);

  using T5 = dtl::argument_traits<int, decltype(sample(0, 0.0))>;
  using E5 = dtl::argument_traits_holder<1, 0, -1, 1, std::tuple<int, double>>;
  BOOST_TEST_TRAIT_SAME(T5, E5);

  return boost::report_errors();
}