Changeset 834
- Timestamp:
- Oct 24, 2003, 8:09:33 AM (22 years ago)
- Location:
- trunk/testcase
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/testcase/throw.cpp
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r833 r834 1 1 #include <stdio.h> 2 2 #include "throw.h" 3 3 4 4 class foo … … 8 8 foo(int i) : i(i) 9 9 { 10 fprintf(stderr, " constructor 1\n");10 fprintf(stderr, "foo::constructor 1\n"); 11 11 } 12 12 13 13 foo() throw(int) : i(1) 14 14 { 15 fprintf(stderr, " constructor 2\n");15 fprintf(stderr, "foo::constructor 2\n"); 16 16 throw(1); 17 17 } … … 29 29 int main() 30 30 { 31 int rc ;31 int rc = 0; 32 32 33 /* static foo - inline implementation */ 33 34 if (o2.get() == 2) 34 35 fprintf(stderr, "o2 ok\n"); 35 36 else 37 { 38 rc++; 36 39 fprintf(stderr, "o2 failed\n"); 40 } 37 41 42 /* foo - inline implementation */ 38 43 try 39 44 { 40 fprintf(stderr, " creating\n");45 fprintf(stderr, "foo creating\n"); 41 46 foo o; 42 fprintf(stderr, "no throw!\n"); 43 rc = o.get(); 47 fprintf(stderr, "foo no throw!\n"); 48 printf("error: foo::foo() didn't throw!\n"); 49 rc += o.get(); 44 50 } 45 51 catch (int e) 46 52 { 47 fprintf(stderr, "caught e=%d\n", e); 48 rc = 0; 53 fprintf(stderr, "foo caught e=%d (ok)\n", e); 54 } 55 56 /* bar - external implementation */ 57 try 58 { 59 fprintf(stderr, "bar creating\n"); 60 bar o; 61 fprintf(stderr, "bar no throw!\n"); 62 printf("error: bar::bar() didn't throw!\n"); 63 rc += o.get(); 64 } 65 catch (int e) 66 { 67 fprintf(stderr, "bar caught e=%d (ok)\n", e); 49 68 } 50 69 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.