summaryrefslogtreecommitdiff
path: root/database.test.c
blob: 966d4f5edcdbb20e1157b40435ec7783031b14ee (plain)
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
#include "test-lib.h"
#include "database.h"

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

// You've really fucking done it now, Mark.
// Not impressed.
const static char* SAMPLE_PATH = "features-facebook-crypto-currency";

int databasePutGetTest() {
  int size;
  size = 1024;
  struct TimeEnty_t input = {
    .direction = IN,
    .datetime = time(NULL)
  };
  struct TimeEnty_t output[1024];
  database_pushEntry(SAMPLE_PATH, &input);
  database_getEntries(SAMPLE_PATH, output, &size);
  if(size != 1) {
    goto fail;
  }
  if(output[0].direction != input.direction) {
    goto fail;
  }
  if(output[0].datetime != input.datetime) {
    goto fail;
  }
  database_nuke(SAMPLE_PATH);
  return 0;
fail:
  database_nuke(SAMPLE_PATH);
  return -1;
}

void database_test() {
  syncTest("database_pushEntry and database_getEntries", "Failed to put then get", databasePutGetTest);
}