stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r559049 - in /incubator/stdcxx/trunk/tests/strings: 21.string.rfind.stdcxx-466.cpp 21.string.stdcxx-466.cpp
Date Tue, 24 Jul 2007 13:27:38 GMT
Author: faridz
Date: Tue Jul 24 06:27:37 2007
New Revision: 559049

URL: http://svn.apache.org/viewvc?view=rev&rev=559049
Log:
2007-07-24 Farid Zaripov <Farid_Zaripov@epam.com>

	* 21.string.rfind.stdcxx-466.cpp: Added testing of find(), find_first_of(),
	find_last_of(), find_first_not_of(), find_last_not_of(), compare() methods.
	File renamed ...
	* 21.string.stdcxx-466: ... to this.

Added:
    incubator/stdcxx/trunk/tests/strings/21.string.stdcxx-466.cpp
      - copied, changed from r558984, incubator/stdcxx/trunk/tests/strings/21.string.rfind.stdcxx-466.cpp
Removed:
    incubator/stdcxx/trunk/tests/strings/21.string.rfind.stdcxx-466.cpp

Copied: incubator/stdcxx/trunk/tests/strings/21.string.stdcxx-466.cpp (from r558984, incubator/stdcxx/trunk/tests/strings/21.string.rfind.stdcxx-466.cpp)
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/strings/21.string.stdcxx-466.cpp?view=diff&rev=559049&p1=incubator/stdcxx/trunk/tests/strings/21.string.rfind.stdcxx-466.cpp&r1=558984&p2=incubator/stdcxx/trunk/tests/strings/21.string.stdcxx-466.cpp&r2=559049
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.rfind.stdcxx-466.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.stdcxx-466.cpp Tue Jul 24 06:27:37 2007
@@ -29,13 +29,29 @@
 
 int main (int argc, char* argv[])
 {
-    std::string s ("abcd");
-    try {
-        assert (std::string::npos == s.rfind ("bc", 0, s.max_size () + 1));
-    }
-    catch (...) {
-        assert (!"Unexpected exception was thrown");
-    }
+    const std::string s ("efgh");
+
+    const std::string::size_type len = s.max_size () + 1;
+
+#define TEST(expr)                                      \
+    try {                                               \
+        assert (expr);                                  \
+    }                                                   \
+    catch (...) {                                       \
+        assert (!"Unexpected exception was thrown");    \
+    } (void)0
+
+    const std::string::size_type npos = std::string::npos;
+
+    TEST (npos == s.find ("fg", 0, len));
+    TEST (npos == s.rfind ("fg", 0, len));
+    TEST (0 == s.find_first_of ("eh", 0, len));
+    TEST (3 == s.find_last_of ("eh", npos, len));
+    TEST (npos == s.find_first_not_of ("eh", 0, len));
+    TEST (npos == s.find_last_not_of ("eh", npos, len));
+    TEST (0 > s.compare (0, npos, "efgh", len));
+    TEST (0 > s.compare (0, npos, "ijkl", len));
+    TEST (0 < s.compare (0, npos, "abcd", len));
 
     return 0;
 }



Mime
View raw message