コード例 #1
0
static PyObject *test(PyObject *self,PyObject *args)
{
    double r;

    fprintf(stderr,"overflow");
    r = overflow(1.e160);
    printerr(r);

    fprintf(stderr,"\ndiv by 0");
    r = db0(0.0);
    printerr(r);

    fprintf(stderr,"\nnested outer");
    r = nest1(0, 0.0);
    printerr(r);

    fprintf(stderr,"\nnested inner");
    r = nest1(1, 1.0);
    printerr(r);

    fprintf(stderr,"\ntrailing outer");
    r = nest1(2, 2.0);
    printerr(r);

    fprintf(stderr,"\nnested prior");
    r = nest2(0, 0.0);
    printerr(r);

    fprintf(stderr,"\nnested interior");
    r = nest2(1, 1.0);
    printerr(r);

    fprintf(stderr,"\nnested trailing");
    r = nest2(2, 2.0);
    printerr(r);

    Py_INCREF (Py_None);
    return Py_None;
}
コード例 #2
0
ファイル: test_GSky.cpp プロジェクト: hsiejkowski/gammalib
/***************************************************************************
 * @brief GSkymap_healpix_construct
 ***************************************************************************/
void TestGSky::test_GSkymap_healpix_construct(void)
{

    // Test void constructor
    test_try("Test void constructor");
    try {
        GSkymap map;
        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test correct Healpix constructors
    test_try("Test correct Healpix constructors");
    try {
        GSkymap ring1("GAL", 1, "RING", 1);
        GSkymap ring2("GAL", 2, "RING", 1);
        GSkymap ring4("GAL", 4, "RING", 1);
        GSkymap ring8("GAL", 8, "RING", 1);
        GSkymap ring16("GAL", 16, "RING", 1);
        GSkymap ring32("GAL", 32, "RING", 1);
        GSkymap ring64("GAL", 64, "RING", 1);
        GSkymap ring128("GAL", 128, "RING", 1);
        GSkymap ring256("GAL", 256, "RING", 1);
        GSkymap ring512("GAL", 512, "RING", 1);
        GSkymap nest1("GAL", 1, "NEST", 1);
        GSkymap nest2("GAL", 2, "NEST", 1);
        GSkymap nest4("GAL", 4, "NEST", 1);
        GSkymap nest8("GAL", 8, "NEST", 1);
        GSkymap nest16("GAL", 16, "NEST", 1);
        GSkymap nest32("GAL", 32, "NEST", 1);
        GSkymap nest64("GAL", 64, "NEST", 1);
        GSkymap nest128("GAL", 128, "NEST", 1);
        GSkymap nest256("GAL", 256, "NEST", 1);
        GSkymap nest512("GAL", 512, "NEST", 1);
        GSkymap map1("CEL", 1, "RING", 1);
        GSkymap map2("CEL", 1, "RING", 2);
        GSkymap map3("EQU", 1, "RING", 1);
        GSkymap map4("EQU", 1, "NESTED", 1);

        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test Healpix copy constructor
    test_try("Test Healpix copy constructor");
    try {
        GSkymap ring1("GAL", 1, "RING", 1);
        GSkymap ring2 = ring1;

        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test invalid coordsys in constructor
    test_try("Test invalid coordsys in constructor");
    try {
        GSkymap map("HOR", 1, "RING", 1);
        test_try_failure();
    }
    catch (GException::wcs_bad_coords &e) {
        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test invalid nside in constructor
    test_try("Test invalid nside in constructor");
    try {
        GSkymap map("GAL", 3, "RING", 1);
        test_try_failure();
    }
    catch (GException::wcs_hpx_bad_nside &e) {
        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test invalid ordering in constructor
    test_try("Test invalid ordering in constructor");
    try {
        GSkymap map("GAL", 2, "SPHERICAL", 1);
        test_try_failure();
    }
    catch (GException::wcs_hpx_bad_ordering &e) {
        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }


    // Test invalid nmaps in constructor
    test_try("Test invalid nmaps in constructor");
    try {
        GSkymap map("GAL", 2, "NEST", 0);
        test_try_failure();
    }
    catch (GException::skymap_bad_par &e) {
        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Exit test
    return;

}