File: TypeTraitsTest.h

package info (click to toggle)
libloki 0.1.7-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,608 kB
  • sloc: cpp: 30,475; ansic: 1,974; makefile: 365; php: 316; perl: 108
file content (117 lines) | stat: -rw-r--r-- 3,588 bytes parent folder | download | duplicates (5)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
///////////////////////////////////////////////////////////////////////////////
// Unit Test for Loki
//
// Copyright Terje Sletteb and Pavel Vozenilek 2002.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose is hereby granted without fee, provided that this copyright and
// permissions notice appear in all copies and derivatives.
//
// This software is provided "as is" without express or implied warranty.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef TYPETRAITSTEST_H
#define TYPETRAITSTEST_H

// $Id: TypeTraitsTest.h 760 2006-10-17 20:36:13Z syntheticpp $


#include <loki/TypeTraits.h>

///////////////////////////////////////////////////////////////////////////////
// TypeTraitsTest
///////////////////////////////////////////////////////////////////////////////

class TypeTraitsTest : public Test
{
public:
  TypeTraitsTest() : Test("TypeTraits.h") {}

  virtual void execute(TestResult &result)
    {
    printName(result);

    using namespace Loki;

    bool r;

    r=TypeTraits<int *>::isPointer &&
      !TypeTraits<int>::isPointer &&
      SameType<TypeTraits<int *>::PointeeType,int>::value &&
      SameType<TypeTraits<int>::PointeeType,NullType>::value &&

      TypeTraits<int &>::isReference &&
      !TypeTraits<int>::isReference &&
      SameType<TypeTraits<int &>::ReferredType,int>::value &&
      SameType<TypeTraits<int>::ReferredType,int>::value &&

      TypeTraits<int Test::*>::isMemberPointer &&
      !TypeTraits<int>::isMemberPointer &&

      TypeTraits<unsigned int>::isStdUnsignedInt &&
      !TypeTraits<int>::isStdUnsignedInt &&

      TypeTraits<int>::isStdSignedInt &&
      !TypeTraits<unsigned int>::isStdSignedInt &&

      TypeTraits<int>::isStdIntegral &&
      !TypeTraits<double>::isStdIntegral &&

      TypeTraits<double>::isStdFloat &&
      !TypeTraits<int>::isStdFloat &&

      TypeTraits<int>::isStdArith &&
      !TypeTraits<void>::isStdArith &&

      TypeTraits<void>::isStdFundamental &&
      !TypeTraits<Test>::isStdFundamental &&

      TypeTraits<unsigned int>::isUnsignedInt &&
      !TypeTraits<int>::isUnsignedInt &&

      TypeTraits<int>::isSignedInt &&
      !TypeTraits<unsigned int>::isSignedInt &&

      TypeTraits<int>::isIntegral &&
      !TypeTraits<double>::isIntegral &&

      TypeTraits<double>::isFloat &&
      !TypeTraits<int>::isFloat &&

      TypeTraits<char>::isArith &&
      TypeTraits<int>::isArith &&
      TypeTraits<double>::isArith &&
      !TypeTraits<void>::isArith &&

      TypeTraits<void>::isFundamental &&
      !TypeTraits<Test>::isFundamental &&

#ifndef __BORLANDC__

      TypeTraits<const int>::isConst &&
      !TypeTraits<int>::isConst &&
      SameType<TypeTraits<const int>::NonConstType,int>::value &&
      SameType<TypeTraits<int>::NonConstType,int>::value &&

      TypeTraits<volatile int>::isVolatile &&
      !TypeTraits<int>::isVolatile &&
      SameType<TypeTraits<volatile int>::NonVolatileType,int>::value &&
      SameType<TypeTraits<int>::NonVolatileType,int>::value &&

      SameType<TypeTraits<const volatile int>::UnqualifiedType,int>::value &&

#endif

      SameType<TypeTraits<char>::ParameterType,char>::value &&
      SameType<TypeTraits<int>::ParameterType,int>::value &&
      SameType<TypeTraits<double>::ParameterType,double>::value &&
      SameType<TypeTraits<Test&>::ParameterType,Test &>::value &&
      SameType<TypeTraits<Test>::ParameterType,const Test &>::value;

    testAssert("TypeTraits",r,result);

    std::cout << '\n';
    }
} typeTraitsTest;

#endif