Author: sebor
Date: Thu Jan 26 14:30:35 2006
New Revision: 372634
URL: http://svn.apache.org/viewcvs?rev=372634&view=rev
Log:
2006-01-26 Martin Sebor <[EMAIL PROTECTED]>
* alg_test.h (UnaryPredicate, BinaryPredicate): Changed the return
type of operator() from bool to conv_to_bool for extra strictness.
Removed dead declarations of tempstr and to_string().
* alg_test.cpp (UnaryPredicate, BinaryPredicate): Same.
Modified:
incubator/stdcxx/trunk/tests/include/alg_test.h
incubator/stdcxx/trunk/tests/src/alg_test.cpp
Modified: incubator/stdcxx/trunk/tests/include/alg_test.h
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/include/alg_test.h?rev=372634&r1=372633&r2=372634&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/include/alg_test.h (original)
+++ incubator/stdcxx/trunk/tests/include/alg_test.h Thu Jan 26 14:30:35 2006
@@ -143,52 +143,7 @@
static int compare (const X*, const X*, _RWSTD_SIZE_T);
};
-
-struct _TEST_EXPORT UnaryPredicate
-{
- // total number of times operator() was invoked
- static _RWSTD_SIZE_T n_total_op_fcall_;
-
- UnaryPredicate ();
-
- UnaryPredicate (const UnaryPredicate&);
-
- UnaryPredicate& operator= (const UnaryPredicate&);
-
- virtual ~UnaryPredicate ();
-
- virtual bool operator()(const X&) const;
-};
-
-
-struct _TEST_EXPORT BinaryPredicate
-{
- // total number of times operator() was invoked
- static _RWSTD_SIZE_T n_total_op_fcall_;
-
- bool ignore_case_;
-
- BinaryPredicate (bool = false);
-
- BinaryPredicate (const BinaryPredicate&);
-
- BinaryPredicate& operator= (const BinaryPredicate&);
-
- virtual ~BinaryPredicate ();
-
- virtual bool operator()(const X&, const X&) const;
-};
-
-
-class _TEST_EXPORT tempstr;
-
-// converts a sequence of objects of type X to a tempstr object
-// in the format "[%p0, %p1): { x0, >x1<, ..., xN - 1 } where N
-// is defined as: N = (X*)p1 - (X*)p0
-// the last argument, if non-negative, indicates the index of the
-// element enclosed in between the '>' and '<' characters
-_TEST_EXPORT void to_string (tempstr*, const X*, const X*, int = -1);
-
+/**************************************************************************/
// generate a unique sequential number starting from 0
_TEST_EXPORT int gen_seq ();
@@ -257,6 +212,7 @@
return true;
}
+/**************************************************************************/
// type used to exercise that algorithms do not apply operators
// to function objects the latter are not required to define
@@ -482,18 +438,44 @@
}
};
+/**************************************************************************/
-#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC
+struct _TEST_EXPORT UnaryPredicate
+{
+ // total number of times operator() was invoked
+ static _RWSTD_SIZE_T n_total_op_fcall_;
-struct DummyBase { };
+ UnaryPredicate ();
-# define ITER_BASE(ign1, ign2, ign3, ign4, ign5) DummyBase
-#else // if defined (_RWSTD_NO_CLASS_PARTIAL_SPEC)
- // when partial specialization isn't supported
-# define ITER_BASE(Cat, T, Dist, Ptr, Ref) \
- std::iterator<Cat, T, Dist, Ptr, Ref >
-#endif // _RWSTD_NO_CLASS_PARTIAL_SPEC
+ UnaryPredicate (const UnaryPredicate&);
+
+ UnaryPredicate& operator= (const UnaryPredicate&);
+
+ virtual ~UnaryPredicate ();
+ virtual conv_to_bool operator()(const X&) const;
+};
+
+
+struct _TEST_EXPORT BinaryPredicate
+{
+ // total number of times operator() was invoked
+ static _RWSTD_SIZE_T n_total_op_fcall_;
+
+ bool ignore_case_;
+
+ BinaryPredicate (bool = false);
+
+ BinaryPredicate (const BinaryPredicate&);
+
+ BinaryPredicate& operator= (const BinaryPredicate&);
+
+ virtual ~BinaryPredicate ();
+
+ virtual conv_to_bool operator()(const X&, const X&) const;
+};
+
+/**************************************************************************/
// Size template argument to fill_n(), generate_n(), and search_n()
template <class IntegralT>
@@ -514,6 +496,19 @@
IntegralT val_;
};
+/**************************************************************************/
+
+#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC
+
+struct DummyBase { };
+
+# define ITER_BASE(ign1, ign2, ign3, ign4, ign5) DummyBase
+#else // if defined (_RWSTD_NO_CLASS_PARTIAL_SPEC)
+ // when partial specialization isn't supported
+# define ITER_BASE(Cat, T, Dist, Ptr, Ref) \
+ std::iterator<Cat, T, Dist, Ptr, Ref >
+#endif // _RWSTD_NO_CLASS_PARTIAL_SPEC
+
// satisfies the requirements in 24.1.1 [lib.input.iterators]
template <class T>
@@ -635,6 +630,7 @@
const value_type *cur_; // past-the-end
};
+/**************************************************************************/
// satisfies the requirements in 24.1.2 [lib.output.iterators]
template <class T>
@@ -761,6 +757,7 @@
pointer cur_;
};
+/**************************************************************************/
// satisfies the requirements in 24.1.3 [lib.forward.iterators]
template <class T>
@@ -844,6 +841,7 @@
_RWSTD_OPERATOR_ARROW (const value_type* operator-> () const);
};
+/**************************************************************************/
// satisfies the requirements in 24.1.4 [lib.bidirectional.iterators]
template <class T>
@@ -938,6 +936,7 @@
_RWSTD_OPERATOR_ARROW (const value_type* operator-> () const);
};
+/**************************************************************************/
// satisfies the requirements in 24.1.5 [lib.random.access.iterators]
template <class T>
@@ -1060,6 +1059,7 @@
const value_type *end_; // past-the-end
};
+/**************************************************************************/
template <class T>
struct ConstRandomAccessIter: RandomAccessIter<T>
@@ -1086,6 +1086,7 @@
}
};
+/**************************************************************************/
template <class T>
inline T*
Modified: incubator/stdcxx/trunk/tests/src/alg_test.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/alg_test.cpp?rev=372634&r1=372633&r2=372634&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/alg_test.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/alg_test.cpp Thu Jan 26 14:30:35 2006
@@ -27,8 +27,9 @@
#include <stdlib.h> // for rand(), strtol()
#include <string.h> // for size_t, strlen()
+
#include <alg_test.h>
-#include <printf.h>
+#include <snprintfa.h>
/* static */ size_t X::count_;
@@ -443,12 +444,12 @@
}
-/* virtual */ bool UnaryPredicate::
+/* virtual */ conv_to_bool UnaryPredicate::
operator()(const X&) const
{
++n_total_op_fcall_;
- return true;
+ return conv_to_bool::make (true);
}
@@ -485,13 +486,13 @@
}
-/* virtual */ bool BinaryPredicate::
+/* virtual */ conv_to_bool BinaryPredicate::
operator()(const X &lhs, const X &rhs) const
{
++n_total_op_fcall_;
if (lhs == rhs)
- return true;
+ return conv_to_bool::make (true);
if (ignore_case_) {
@@ -500,15 +501,15 @@
if ( lval < 0 || lval > int (_RWSTD_UCHAR_MAX)
|| rval < 0 || rval > int (_RWSTD_UCHAR_MAX))
- return false;
+ return conv_to_bool::make (false);
const int lup = toupper (lval);
const int rup = toupper (rval);
- return _RWSTD_EOF != lup && lup == rup;
+ return conv_to_bool::make (_RWSTD_EOF != lup && lup == rup);
}
- return false;
+ return conv_to_bool::make (false);
}