Changeset 834


Ignore:
Timestamp:
Oct 24, 2003, 8:09:33 AM (22 years ago)
Author:
bird
Message:

Extended testcase.

Location:
trunk/testcase
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/testcase/throw.cpp

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r833 r834  
    11#include <stdio.h>
    2 
     2#include "throw.h"
    33
    44class foo
     
    88    foo(int i) : i(i)
    99    {
    10         fprintf(stderr, "constructor 1\n");
     10        fprintf(stderr, "foo::constructor 1\n");
    1111    }
    1212
    1313    foo() throw(int) : i(1)
    1414    {
    15         fprintf(stderr, "constructor 2\n");
     15        fprintf(stderr, "foo::constructor 2\n");
    1616        throw(1);
    1717    }
     
    2929int main()
    3030{
    31     int rc;
     31    int rc = 0;
    3232
     33    /* static foo - inline implementation */
    3334    if (o2.get() == 2)
    3435        fprintf(stderr, "o2 ok\n");
    3536    else
     37    {
     38        rc++;
    3639        fprintf(stderr, "o2 failed\n");
     40    }
    3741
     42    /* foo - inline implementation */
    3843    try
    3944    {
    40         fprintf(stderr, "creating\n");
     45        fprintf(stderr, "foo creating\n");
    4146        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();
    4450    }
    4551    catch (int e)
    4652    {
    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);
    4968    }
    5069
Note: See TracChangeset for help on using the changeset viewer.