forked from libxmp/libxmp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api_load_module_from_memory.c
More file actions
74 lines (54 loc) · 1.79 KB
/
Copy pathtest_api_load_module_from_memory.c
File metadata and controls
74 lines (54 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <stdio.h>
#include "test.h"
#define BUFFER_SIZE 256000
static unsigned char *buffer;
TEST(test_api_load_module_from_memory)
{
xmp_context ctx;
struct xmp_frame_info fi;
int ret, size;
FILE *f;
buffer = malloc(BUFFER_SIZE);
fail_unless(buffer != NULL, "buffer allocation");
ctx = xmp_create_context();
f = fopen("data/test.xm", "rb");
fail_unless(f != NULL, "can't open module");
size = fread(buffer, 1, BUFFER_SIZE, f);
fclose(f);
/* valid file */
ret = xmp_load_module_from_memory(ctx, buffer, size);
fail_unless(ret == 0, "load file");
xmp_get_frame_info(ctx, &fi);
fail_unless(fi.total_time == 15360, "module duration");
f = fopen("data/test.it", "rb");
fail_unless(f != NULL, "can't open module");
size = fread(buffer, 1, BUFFER_SIZE, f);
fclose(f);
/* and reload without releasing */
ret = xmp_load_module_from_memory(ctx, buffer, size);
fail_unless(ret == 0, "load file");
xmp_get_frame_info(ctx, &fi);
fail_unless(fi.total_time == 7680, "module duration");
/* reported crashing in 4.2.0 by Andreas Argirakis */
xmp_release_module(ctx);
f = fopen("data/m/reborning.mod", "rb");
fail_unless(f != NULL, "can't open module");
size = fread(buffer, 1, BUFFER_SIZE, f);
fclose(f);
ret = xmp_load_module_from_memory(ctx, buffer, size);
fail_unless(ret == 0, "load file");
xmp_get_frame_info(ctx, &fi);
fail_unless(fi.total_time == 107520, "module duration");
/* load through a prowizard converter */
xmp_release_module(ctx);
f = fopen("data/m/mod.sad-song", "rb");
fail_unless(f != NULL, "can't open module");
size = fread(buffer, 1, BUFFER_SIZE, f);
fclose(f);
ret = xmp_load_module_from_memory(ctx, buffer, size);
fail_unless(ret == 0, "load file");
xmp_get_frame_info(ctx, &fi);
fail_unless(fi.total_time == 235520, "module duration");
free(buffer);
}
END_TEST