~laney/ubuntu/vivid/0ad/test

« back to all changes in this revision

Viewing changes to libraries/source/cxxtest/sample/ExceptionTest.h

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2014-05-17 16:30:39 UTC
  • mfrom: (5.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20140517163039-whlz3xf64hbmi8x1
Tags: 0.0.16-1
* New upstream release.
  - Drop debian/patches/fix-kfreebsd-ftbfs.patch; applied upstream.
* Avoid repacking tarball by including missing jquery sources in Debian diff,
  see debian/missing-sources/jquery-1.8.{0,3}.js. Alternative way of fixing
  #735349.
  - Update debian/copyright to include missing license entries for the
    various javascript libraries contained in the source tarball.
  - Revert changes made to debian/control in 0ad/0.0.15+dfsg-3, i.e.:
    revert: debian/control: Hardcode versions of 0ad-data{,-common} to
            depend on to workaround the fact that 0.0.15+dfsg is strictly
            greater than 0.0.15.
* Build-dep on libgloox-dev (>= 1.0.9) to ensure that 0ad is built with
  newer enough gloox to avoid lobby connectivity issues.
* Add new build-deps: libicu-dev, libmozjs-24-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef __EXCEPTIONTEST_H
2
 
#define __EXCEPTIONTEST_H
3
 
 
4
 
#include <cxxtest/TestSuite.h>
5
 
 
6
 
//
7
 
// This test suite demonstrates the use of TS_ASSERT_THROWS
8
 
//
9
 
 
10
 
class ExceptionTest : public CxxTest::TestSuite
11
 
{
12
 
public:
13
 
    void testAssertion( void )
14
 
    {
15
 
        // This assert passes, since throwThis() throws (Number)
16
 
        TS_ASSERT_THROWS( throwThis(3), const Number & );
17
 
        // This assert passes, since throwThis() throws something
18
 
        TS_ASSERT_THROWS_ANYTHING( throwThis(-30) );
19
 
        // This assert fails, since throwThis() doesn't throw char *
20
 
        TS_ASSERT_THROWS( throwThis(5), const char * );
21
 
        // This assert fails since goodFunction() throws nothing
22
 
        TS_ASSERT_THROWS_ANYTHING( goodFunction(1) );
23
 
        // The regular TS_ASSERT macros will catch unhandled exceptions
24
 
        TS_ASSERT_EQUALS( throwThis(3), 333 );
25
 
        // You can assert that a function throws nothing
26
 
        TS_ASSERT_THROWS_NOTHING( throwThis(-1) );
27
 
        // If you want to catch the exceptions yourself, use the ETS_ marcos
28
 
        try {
29
 
            ETS_ASSERT_EQUALS( throwThis(3), 333 );
30
 
        } catch( const Number & ) {
31
 
            TS_FAIL( "throwThis(3) failed" );
32
 
        }
33
 
    }
34
 
 
35
 
private:
36
 
    void goodFunction( int )
37
 
    {
38
 
    }
39
 
 
40
 
    class Number
41
 
    {
42
 
    public:
43
 
        Number( int ) {}
44
 
    };
45
 
    
46
 
    int throwThis( int i )
47
 
    {
48
 
        throw Number( i );
49
 
    }
50
 
};
51
 
 
52
 
#endif // __EXCEPTIONTEST_H