APEMoST
Defines | Functions | Variables

tests/tests.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mcmc.h"
#include "mcmc_internal.h"
#include "debug.h"
#include "gsl_helper.h"
#include "histogram.h"

Defines

#define CIRCULAR_PARAMS   1,2
#define DUMPONFAIL   1
#define ASSERTDUMP(condition, text, a)
#define ASSERT(condition, text)   ASSERTDUMP(condition, text, NULL)
#define ASSERTEQUALI(result, expected, text)
#define ASSERTEQUALD(result, expected, text)

Functions

int count_tests ()
int test_tests (void)
int test_hist (void)
int test_create (void)
int test_load (void)
int test_append (void)
int test_random (void)
int test_mod (void)
int test_write (void)
int test_write_prob (void)
void calc_prob (mcmc *m)
void calc_model (mcmc *m, const gsl_vector *old_values)
void calc_model_for (mcmc *m, const unsigned int index, const double old_value)

Variables

int(* tests_registration [])(void)

Define Documentation

#define ASSERT (   condition,
  text 
)    ASSERTDUMP(condition, text, NULL)

Referenced by test_load(), and test_random().

#define ASSERTDUMP (   condition,
  text,
 
)
Value:
{ \
                if(!(condition)) { \
                        printf("  ASSERT FAILED: %s\n",text); \
                        if(DUMPONFAIL && a != NULL){ \
                                printf("    dump: \n"); \
                                dump_mcmc(a); \
                        } \
                        return 1; \
                } else { \
                        printf("  subtest ok: %s\n",text); \
                } \
        }
#define ASSERTEQUALD (   result,
  expected,
  text 
)
Value:
{ \
                if((expected) == (result) || \
                        abs_double((expected) - (result)) < abs_double((expected)+(result))*0.001 \
                ) { \
                        printf("  subtest ok: %s\n", text); \
                } else { \
                        printf("  ASSERT EQUAL FAILED: expected: %e; got: %e; %s\n", expected, result, text); \
                        printf("  ASSERT CODE TERM: %s\n", #result); \
                        return 1; \
                } \
        }

Referenced by test_hist(), test_load(), test_mod(), and test_random().

#define ASSERTEQUALI (   result,
  expected,
  text 
)
Value:
{ \
                if(expected != result) { \
                        printf("  ASSERT EQUAL FAILED: expected: %d; got: %d; %s\n", expected, result, text); \
                        printf("  ASSERT CODE: %s\n", #expected); \
                        return 1; \
                } else { \
                        printf("  subtest ok: %s\n", text); \
                } \
        }

Referenced by test_append(), test_create(), test_hist(), test_load(), and test_write_prob().

#define CIRCULAR_PARAMS   1,2
#define DUMPONFAIL   1

Function Documentation

void calc_model ( mcmc m,
const gsl_vector *  old_values 
)

update the model according to the new parameter values and recalculate the probability for the model

Parameters:
m
old_valuesprevious values, or NULL

Referenced by calc_model_for(), calibrate_first(), calibrate_rest(), main(), and markov_chain_step().

void calc_model_for ( mcmc m,
const unsigned int  i,
const double  old_value 
)

update the model as the new parameter value i changed and recalculate the probability for the model

Parameters:
m
iindex of the parameter value that changed
old_valueprevious value of the parameter

Referenced by main(), and markov_chain_step_for().

void calc_prob ( mcmc m)
int count_tests ( )

References tests_registration.

Referenced by test(), test_all(), test_tests(), and usage().

int test_append ( void  )
int test_create ( void  )
int test_hist ( void  )
int test_load ( void  )
int test_mod ( void  )

References ASSERTEQUALD, and mod_double.

int test_random ( void  )
int test_tests ( void  )

References count_tests().

int test_write ( void  )
int test_write_prob ( void  )

Variable Documentation

int(* tests_registration[])(void)