Changeset 835 for trunk/testcase


Ignore:
Timestamp:
Oct 24, 2003, 9:19:00 AM (22 years ago)
Author:
bird
Message:

Extended testcase.

Location:
trunk/testcase
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/testcase/throw.cpp

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r834 r835  
    2222    }
    2323
     24    int getthrow() const throw(int)
     25    {
     26        throw(2);
     27        return i;
     28    }
    2429};
    2530
    2631
    2732static foo  o2(2);
     33static bar  o3(3);
    2834
    2935int main()
     
    3844        rc++;
    3945        fprintf(stderr, "o2 failed\n");
     46    }
     47    try
     48    {
     49        rc += o2.getthrow();
     50        printf("error: foo::getthrow() didn't throw!\n");
     51    }
     52    catch (int e)
     53    {
     54        fprintf(stderr, "foo caught e=%d (ok)\n", e);
    4055    }
    4156
     
    5267    {
    5368        fprintf(stderr, "foo caught e=%d (ok)\n", e);
     69    }
     70
     71
     72    /* static bar - external implementation */
     73    if (o3.get() == 3)
     74        fprintf(stderr, "o3 ok\n");
     75    else
     76    {
     77        rc++;
     78        fprintf(stderr, "o3 failed\n");
     79    }
     80    try
     81    {
     82        rc += o3.getThrow();
     83        printf("error: bar:getThrow() didn't throw!\n");
     84    }
     85    catch (expt e)
     86    {
     87        fprintf(stderr, "foo caught e=%d (ok)\n", e.get());
    5488    }
    5589
  • trunk/testcase/throw.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r834 r835  
     1class expt
     2{
     3private:
     4    int i;
     5    const char *psz;
     6
     7public:
     8    expt(int i, const char *psz);
     9    int get() const;
     10};
     11
    112class bar
    213{
     
    617    bar() throw(int);
    718    int get() const;
     19    int getThrow() const throw(expt);
    820};
    921
  • trunk/testcase/throw2.cpp

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r834 r835  
    1717    return i;
    1818}
     19
     20int bar::getThrow() const throw(expt)
     21{
     22    throw(expt(1, ""));
     23    return 1;
     24}
     25
     26
     27
     28expt::expt(int i, const char *psz) : i(i), psz(psz)
     29{
     30
     31}
     32
     33int expt::get() const
     34{
     35    return i;
     36}
     37
     38
Note: See TracChangeset for help on using the changeset viewer.