2012-02-18 15:11:46 -02:00
|
|
|
#include <xmp.h>
|
2021-07-19 00:17:51 +01:00
|
|
|
#include <math.h>
|
2012-02-18 15:11:46 -02:00
|
|
|
|
2021-07-06 17:26:33 +01:00
|
|
|
#if defined(_MSC_VER) || defined(__WATCOMC__)
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#else
|
2021-06-06 23:44:50 +01:00
|
|
|
#include <unistd.h>
|
2021-07-06 17:26:33 +01:00
|
|
|
#endif
|
|
|
|
|
|
2012-03-07 16:26:48 -03:00
|
|
|
#include "../src/common.h"
|
2021-06-03 18:51:16 -06:00
|
|
|
#include "../src/md5.h"
|
2012-03-07 16:26:48 -03:00
|
|
|
|
2012-02-18 15:11:46 -02:00
|
|
|
#define TMP_FILE ".test"
|
|
|
|
|
|
|
|
|
|
#define TEST_FUNC(x) int _test_func_##x(void)
|
|
|
|
|
|
2012-03-07 16:26:48 -03:00
|
|
|
#undef TEST
|
2012-02-18 15:11:46 -02:00
|
|
|
#define TEST(x) TEST_FUNC(x) {
|
|
|
|
|
|
|
|
|
|
#define END_TEST \
|
|
|
|
|
return 0; }
|
|
|
|
|
|
2021-06-09 11:46:18 +01:00
|
|
|
#if defined(_WIN32) || defined(__riscos__)
|
2020-10-30 22:18:22 -06:00
|
|
|
/* exit() prevents the failure message from being printed! */
|
|
|
|
|
#define FAIL_MSG "**fail**\n"
|
|
|
|
|
#else
|
|
|
|
|
#define FAIL_MSG
|
|
|
|
|
#endif
|
2012-02-18 15:11:46 -02:00
|
|
|
#define fail_unless(x, y) do { \
|
2020-10-30 22:18:22 -06:00
|
|
|
if (!(x)) { printf("at %s:%d: %s: " FAIL_MSG, __FILE__, __LINE__, y); exit(1); } \
|
2012-02-18 15:11:46 -02:00
|
|
|
} while (0)
|
|
|
|
|
|
2013-05-15 18:12:03 -03:00
|
|
|
static inline int is_big_endian() {
|
|
|
|
|
uint16 w = 0x00ff;
|
|
|
|
|
return (*(char *)&w == 0x00);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-19 00:17:51 +01:00
|
|
|
static inline double libxmp_round(double val)
|
|
|
|
|
{
|
|
|
|
|
return (val >= 0.0)? floor(val + 0.5) : ceil(val - 0.5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get period from note */
|
|
|
|
|
static inline int note_to_period(int n)
|
|
|
|
|
{
|
|
|
|
|
return (int)libxmp_round (13696.0 / pow(2, (double)n / 12));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define PERIOD ((int)libxmp_round(1.0 * info.channel_info[0].period / 4096))
|
|
|
|
|
|
2021-11-20 18:19:43 -07:00
|
|
|
enum playback_action
|
|
|
|
|
{
|
|
|
|
|
PLAY_END,
|
|
|
|
|
PLAY_FRAMES,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct playback_sequence
|
|
|
|
|
{
|
|
|
|
|
enum playback_action action;
|
|
|
|
|
int value;
|
|
|
|
|
int result;
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-29 15:18:34 -03:00
|
|
|
int map_channel(struct player_data *, int);
|
2012-03-07 23:47:00 -03:00
|
|
|
int play_frame(struct context_data *);
|
|
|
|
|
|
2012-02-18 15:11:46 -02:00
|
|
|
|
2013-09-08 17:41:13 -03:00
|
|
|
int compare_module(struct xmp_module *, FILE *);
|
2020-10-30 21:51:08 -06:00
|
|
|
void dump_module(struct xmp_module *, FILE *);
|
2021-11-20 18:19:43 -07:00
|
|
|
void compare_playback(const char *, const struct playback_sequence *, int, int, int);
|
2021-07-28 18:37:00 +03:00
|
|
|
int compare_md5(const unsigned char *, const char *);
|
|
|
|
|
int check_md5(const char *, const char *);
|
2015-02-18 14:10:55 -02:00
|
|
|
int check_randomness(int *, int, double);
|
2021-06-24 00:42:42 -06:00
|
|
|
void read_file_to_memory(const char *, void **, long *);
|
2021-07-28 18:37:00 +03:00
|
|
|
void compare_mixer_data(const char *, const char *);
|
|
|
|
|
void compare_mixer_data_loops(const char *, const char *, int);
|
|
|
|
|
void compare_mixer_data_no_rv(const char *, const char *);
|
2013-04-29 20:21:30 -03:00
|
|
|
void convert_endian(unsigned char *, int);
|
2012-03-09 08:50:05 -03:00
|
|
|
void create_simple_module(struct context_data *, int, int);
|
2012-03-14 09:43:54 -03:00
|
|
|
void set_order(struct context_data *, int, int);
|
2012-03-08 09:19:32 -03:00
|
|
|
void set_instrument_volume(struct context_data *, int, int, int);
|
2012-03-12 07:05:39 -03:00
|
|
|
void set_instrument_nna(struct context_data *, int, int, int, int, int);
|
|
|
|
|
void set_instrument_envelope(struct context_data *, int, int, int, int);
|
|
|
|
|
void set_instrument_envelope_sus(struct context_data *, int, int);
|
2012-03-12 14:26:22 -03:00
|
|
|
void set_instrument_fadeout(struct context_data *, int, int);
|
2016-07-03 22:10:33 -03:00
|
|
|
void set_period_type(struct context_data *, int);
|
2012-03-09 14:54:57 -03:00
|
|
|
void set_quirk(struct context_data *, int, int);
|
2013-04-08 10:11:18 -03:00
|
|
|
void reset_quirk(struct context_data *, int);
|
2012-03-07 16:26:48 -03:00
|
|
|
void new_event(struct context_data *, int, int, int, int, int, int, int, int, int, int);
|
2012-02-18 15:11:46 -02:00
|
|
|
|
2012-03-06 00:20:27 -03:00
|
|
|
#define declare_test(x) TEST_FUNC(x)
|
|
|
|
|
#include "all_tests.c"
|
|
|
|
|
#undef declare_test
|