OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [testsuite_tr1.h] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// -*- C++ -*-
2
// Testing utilities for the tr1 testsuite.
3
//
4
// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5
//
6
// This file is part of the GNU ISO C++ Library.  This library is free
7
// software; you can redistribute it and/or modify it under the
8
// terms of the GNU General Public License as published by the
9
// Free Software Foundation; either version 2, or (at your option)
10
// any later version.
11
//
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
// GNU General Public License for more details.
16
//
17
// You should have received a copy of the GNU General Public License along
18
// with this library; see the file COPYING.  If not, write to the Free
19
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
// USA.
21
//
22
// As a special exception, you may use this file as part of a free software
23
// library without restriction.  Specifically, if other files instantiate
24
// templates or use macros or inline functions from this file, or you compile
25
// this file and link it with other files to produce an executable, this
26
// file does not by itself cause the resulting executable to be covered by
27
// the GNU General Public License.  This exception does not however
28
// invalidate any other reasons why the executable file might be covered by
29
// the GNU General Public License.
30
 
31
#ifndef _GLIBCXX_TESTSUITE_TR1_H
32
#define _GLIBCXX_TESTSUITE_TR1_H
33
 
34
namespace __gnu_test
35
{
36
  // For tr1/type_traits.
37
  template<template<typename> class Category,
38
           typename Type>
39
    bool
40
    test_category(bool value)
41
    {
42
      bool ret = true;
43
      ret &= Category<Type>::value == value;
44
      ret &= Category<const Type>::value == value;
45
      ret &= Category<volatile Type>::value == value;
46
      ret &= Category<const volatile Type>::value == value;
47
      ret &= Category<Type>::type::value == value;
48
      ret &= Category<const Type>::type::value == value;
49
      ret &= Category<volatile Type>::type::value == value;
50
      ret &= Category<const volatile Type>::type::value == value;
51
      return ret;
52
    }
53
 
54
  template<template<typename> class Property,
55
           typename Type>
56
    bool
57
    test_property(typename Property<Type>::value_type value)
58
    {
59
      bool ret = true;
60
      ret &= Property<Type>::value == value;
61
      ret &= Property<Type>::type::value == value;
62
      return ret;
63
    }
64
 
65
  template<template<typename, typename> class Relationship,
66
           typename Type1, typename Type2>
67
    bool
68
    test_relationship(bool value)
69
    {
70
      bool ret = true;
71
      ret &= Relationship<Type1, Type2>::value == value;
72
      ret &= Relationship<Type1, Type2>::type::value == value;
73
      return ret;
74
    }
75
 
76
  // Test types.
77
  class ClassType { };
78
  typedef const ClassType           cClassType;
79
  typedef volatile ClassType        vClassType;
80
  typedef const volatile ClassType  cvClassType;
81
 
82
  class DerivedType : public ClassType { };
83
 
84
  enum EnumType { };
85
 
86
  struct ConvType
87
  { operator int() const; };
88
 
89
  class AbstractClass
90
  {
91
    virtual void rotate(int) = 0;
92
    virtual ~AbstractClass();
93
  };
94
 
95
  class PolymorphicClass
96
  {
97
    virtual void rotate(int);
98
    virtual ~PolymorphicClass();
99
  };
100
 
101
  class DerivedPolymorphic : public PolymorphicClass { };
102
 
103
  union UnionType { };
104
 
105
  class IncompleteClass;
106
 
107
  int truncate_float(float x) { return (int)x; }
108
  long truncate_double(double x) { return (long)x; }
109
 
110
  struct do_truncate_float_t
111
  {
112
    do_truncate_float_t()
113
    {
114
      ++live_objects;
115
    }
116
 
117
    do_truncate_float_t(const do_truncate_float_t&)
118
    {
119
      ++live_objects;
120
    }
121
 
122
    ~do_truncate_float_t()
123
    {
124
      --live_objects;
125
    }
126
 
127
    int operator()(float x) { return (int)x; }
128
 
129
    static int live_objects;
130
  };
131
 
132
  int do_truncate_float_t::live_objects = 0;
133
 
134
  struct do_truncate_double_t
135
  {
136
    do_truncate_double_t()
137
    {
138
     ++live_objects;
139
    }
140
 
141
    do_truncate_double_t(const do_truncate_double_t&)
142
    {
143
      ++live_objects;
144
    }
145
 
146
    ~do_truncate_double_t()
147
    {
148
      --live_objects;
149
    }
150
 
151
    long operator()(double x) { return (long)x; }
152
 
153
    static int live_objects;
154
  };
155
 
156
  int do_truncate_double_t::live_objects = 0;
157
 
158
  struct X
159
  {
160
    int bar;
161
 
162
    int foo()                   { return 1; }
163
    int foo_c() const           { return 2; }
164
    int foo_v()  volatile       { return 3; }
165
    int foo_cv() const volatile { return 4; }
166
  };
167
} // namespace __gnu_test
168
 
169
#endif // _GLIBCXX_TESTSUITE_TR1_H

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.