/* $Id: kmo_fits_check-test.c,v 1.4 2013-10-08 11:18:56 aagudo Exp $
 *
 * This file is part of the KMOS Library
 * Copyright (C) 2002-2006 European Southern Observatory
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

/*
 * $Author: aagudo $
 * $Date: 2013-10-08 11:18:56 $
 * $Revision: 1.4 $
 * $Name: not supported by cvs2svn $
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>

#include <cpl.h>

#include "kmo_test_create_data.h"

/**
    @defgroup kmo_fits_check_test   kmo_fits_check unit tests

    @{
*/

/**
 * @brief   test
 */
static void test_fits_check(const char *option, int ret_val)
{
    // create esorex-command
    char esorex_command[256];
    sprintf(esorex_command,
            "esorex --suppress-prefix=TRUE kmo_fits_check %s %s", option,
            " ../../recipes/tests/ref_data/KMOS_dummy.fits");

    kmo_get_pipe_command(esorex_command,
                         "log_kmo_fits_check.txt", NULL, TRUE);

    // execute esorex-command
    if (ret_val == 0) {
        cpl_test_eq(0, system(esorex_command));
    } else {
        cpl_test_noneq(0, system(esorex_command));
    }
}

/**
  @brief	Test of kmo_fits_check recipe.
 */
int main()
{
    cpl_test_init("<kmos-spark@mpe.mpg.de>", CPL_MSG_WARNING);

    /* ----- run the tests ----- */
    FILE *fd = fopen("log_kmo_fits_check.txt", "w");
    fprintf(fd, "%s\n", " ");
    fclose(fd);

    test_fits_check("", 0);
    test_fits_check("--h=-1", 0);
    test_fits_check("--d=-1", 0);
    test_fits_check("--h=1", 0);
    test_fits_check("--d=1", 0);
    test_fits_check("--h=2", 0);
    test_fits_check("--d=2", 0);
    test_fits_check("--h=3", 0);
    test_fits_check("--d=3", 0);
    test_fits_check("--gaga", -1);
    
    return cpl_test_end(0);
}

/** @} */
