This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[v3] stdexcept, more tests



I believe this to be the last of this set...

2001-02-27  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/std_stdexcept.h (runtime_error): Make string
	member non-const.
	(logic_error): Same.
	* testsuite/19_diagnostics/stdexceptions.cc (test04): Add test.
	(test03): Fix.

Index: include/bits/std_stdexcept.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/std_stdexcept.h,v
retrieving revision 1.5
diff -c -p -r1.5 std_stdexcept.h
*** std_stdexcept.h	2001/02/27 04:13:17	1.5
--- std_stdexcept.h	2001/02/27 22:58:29
*************** namespace std 
*** 43,49 ****
  {
    class logic_error : public exception 
    {
!     const string _M_msg;
  
    public:
      explicit 
--- 43,49 ----
  {
    class logic_error : public exception 
    {
!     string _M_msg;
  
    public:
      explicit 
*************** namespace std 
*** 82,88 ****
  
    class runtime_error : public exception 
    {
!     const string _M_msg;
  
    public:
      explicit 
--- 82,88 ----
  
    class runtime_error : public exception 
    {
!     string _M_msg;
  
    public:
      explicit 
Index: testsuite/19_diagnostics/stdexceptions.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/19_diagnostics/stdexceptions.cc,v
retrieving revision 1.3
diff -c -p -r1.3 stdexceptions.cc
*** stdexceptions.cc	2001/02/27 16:16:12	1.3
--- stdexceptions.cc	2001/02/27 22:58:29
*************** void test03()
*** 69,80 ****
      { VERIFY( false ); }
  }
  
  
  int main(void)
  {
    test01();
    test02();
    test03();
!   
    return 0;
  }
--- 69,116 ----
      { VERIFY( false ); }
  }
  
+ // test copy ctors and assignment operators
+ // libstdc++/1972
+ // via Greg Bumgardner <bumgard@roguewave.com>
+ void allocate_on_stack(void) 
+ {
+   const size_t num = 512;
+   __extension__ char array[num];
+   for (size_t i = 0; i < num; i++) 
+     array[i]=0;
+ }
+ void test04()
+ {
+   const std::string s("CA ISO emergency once again:immediate power down");
+   const char* strlit1 = "wish I lived in Palo Alto";
+   const char* strlit2 = "...or Santa Barbara";
+   std::runtime_error obj1(s);
+   
+   // block 01
+   {
+     const std::string s2(strlit1);
+     std::runtime_error obj2(s2);
+     obj1 = obj2;
+   }
+   allocate_on_stack();
+   VERIFY( strcmp(strlit1, obj1.what()) == 0 ); 
  
+   // block 02
+   {
+     const std::string s3(strlit2);
+     std::runtime_error obj3 = std::runtime_error(s3);
+     obj1 = obj3;
+   }
+   allocate_on_stack();     
+   VERIFY( strcmp(strlit2, obj1.what()) == 0 ); 
+ }
+ 
  int main(void)
  {
    test01();
    test02();
    test03();
!   test04();
! 
    return 0;
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]