-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_dna_sequence.c
73 lines (53 loc) · 1.9 KB
/
test_dna_sequence.c
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
#include "test.h"
#include <genomics/data/dna_sequence.h>
#include <genomics/data/dna_codec.h>
#include <core/system/memory.h>
#include <core/system/memory_pool.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
BEGIN_TESTS();
void *buffer;
struct biosal_dna_sequence sequence;
struct biosal_dna_sequence sequence2;
struct biosal_dna_codec codec;
int actual;
int expected;
int required;
void *buffer_for_pack;
struct core_memory_pool memory;
core_memory_pool_init(&memory, 4194304, -1);
buffer = core_memory_allocate(101, -1);
strcpy((char *)buffer, "TCCCGAGCGCAGGTAGGCCTCGGGATCGATGTCCGGGGTGTTGAGGATGTTGGACGTGTATTCGTGGTTGTACTGGGTCCAGTCCGCCACCGGGCGCCGC");
biosal_dna_codec_init(&codec);
biosal_dna_sequence_init(&sequence, buffer, &codec, &memory);
actual = biosal_dna_sequence_length(&sequence);
expected = 100;
/*
printf("DEBUG actual %d expected %d\n", actual, expected);
*/
TEST_INT_EQUALS(actual, expected);
required = biosal_dna_sequence_pack_size(&sequence, &codec);
TEST_INT_IS_GREATER_THAN(required, 0);
buffer_for_pack = core_memory_allocate(required, -1);
/*
printf("DEBUG buffer %p size for pack/unpack has %d bytes\n",
buffer_for_pack, required);
*/
biosal_dna_sequence_pack(&sequence, buffer_for_pack, &codec);
biosal_dna_sequence_unpack(&sequence2, buffer_for_pack, &memory, &codec);
actual = biosal_dna_sequence_length(&sequence2);
/*
printf("DEBUG actual %d expected %d\n", actual, expected);
*/
TEST_INT_EQUALS(actual, expected);
biosal_dna_sequence_destroy(&sequence, &memory);
biosal_dna_sequence_destroy(&sequence2, &memory);
biosal_dna_codec_destroy(&codec);
core_memory_pool_destroy(&memory);
END_TESTS();
core_memory_free(buffer, -1);
core_memory_free(buffer_for_pack, -1);
return 0;
}