acinclude.m4, [...]: Change sourceware.cygnus.com and sources.redhat.com URLs for...
[gcc.git] / libstdc++-v3 / testsuite / 27_io / ifstream_members.cc
index 9b4107a66051244ad8cc8b4865e3dc18e25992c0..e87aa76016a3c4cf97edeae2a465d43c07c8969c 100644 (file)
 
 #include <istream>
 #include <fstream>
-#ifdef DEBUG_ASSERT
-  #include <assert.h>
-#endif
+#include <debug_assert.h>
 
 const char name_01[] = "testsuite/ifstream_members-1.tst";
 const char name_02[] = "testsuite/ifstream_members-1.txt";
 
-// http://sourceware.cygnus.com/ml/libstdc++/2000-06/msg00136.html
+// http://gcc.gnu.org/ml/libstdc++/2000-06/msg00136.html
 bool test00()
 {
   bool test = true;
@@ -35,15 +33,15 @@ bool test00()
   ifs1.close();
   
   // false as expected:
-  test &= !ifs1.is_open();
+  VERIFY( !ifs1.is_open() );
    // this is now true:
-  test &= !(ifs1);
+  VERIFY( !(ifs1) );
   
   ifs1.open(name_01);
-  test &= ifs1.is_open();
+  VERIFY( ifs1.is_open() );
   // fail bit still true
-  test &= !(ifs1);
-  test &= ifs1.rdstate() == std::ios_base::failbit;
+  VERIFY( !(ifs1) );
+  VERIFY( ifs1.rdstate() == std::ios_base::failbit );
 
   ifs1.close();
 
@@ -54,7 +52,28 @@ bool test00()
   return test;
 }
 
+// http://gcc.gnu.org/ml/libstdc++/2000-07/msg00004.html
+bool test01()
+{
+  bool test = true;
+  const int more_than_max_open_files = 8200;
+  
+  for(int i = 0; ++i < more_than_max_open_files;)
+    {
+      std::ifstream ifs(name_01);
+      VERIFY( static_cast<bool>(ifs) );
+    }
+
+#ifdef DEBUG_ASSERT
+  assert(test);
+#endif
+  return test;
+}
+
+
 int main()
 {
   test00();
+  test01();
 }