Skip to content

Commit 4a6a0ab

Browse files
author
Damien Churchill
committed
add tests for action
1 parent 8fb71d0 commit 4a6a0ab

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

action.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,9 @@
1818
*
1919
*/
2020

21+
#include <stdlib.h>
2122
#include "action.h"
2223

23-
typedef struct bs_action_t *Action;
24-
25-
typedef enum {
26-
HASH_CHUNK,
27-
END_THREAD
28-
} bs_action_type;
29-
30-
struct bs_action_t {
31-
bs_action_type type;
32-
void *data;
33-
};
34-
3524
/**
3625
* Create a new thread message
3726
*/

testAction.c

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <assert.h>
2+
#include <string.h>
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include "action.h"
6+
7+
void test_action();
8+
9+
int main(int argc, char **argv)
10+
{
11+
printf("Running test_action()\n");
12+
test_action();
13+
14+
return 0;
15+
}
16+
17+
void test_action() {
18+
char *buffer;
19+
Action action;
20+
21+
buffer = malloc(20);
22+
memcpy(buffer, "thisrandomteststring", 20);
23+
24+
action = bs_new_action(HASH_CHUNK, buffer);
25+
26+
assert(memcmp(action->data, buffer, 20) == 0);
27+
assert(action->type == HASH_CHUNK);
28+
29+
free(buffer);
30+
31+
assert(memcmp(action->data, "thisrandomteststring", 20) != 0);
32+
}

0 commit comments

Comments
 (0)