blob: 4998084bced69ed59f7f5b7654552deefdc10296 [file] [log] [blame]
#include "../dial_data.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "test.h"
int key_value_pairs = 3;
char *keys[] = {"key1", "key2", "key3"};
char *values[] = {"value1", "value2", "value3"};
void test_read_dial_data() {
DIALData *data = retrieve_dial_data("dial_data");
for (int i = 0; data != NULL; data = data->next, i++) {
EXPECT_STREQ(data->key, keys[2 - i]);
EXPECT_STREQ(data->value, values[2 - i]);
}
DONE();
}
void test_write_dial_data() {
DIALData *result = NULL;
for (int i = 0; i < key_value_pairs; ++i) {
DIALData *node = (DIALData *) malloc(sizeof(DIALData));
node->key = keys[i];
node->value = values[i];
node->next = result;
result = node;
}
store_dial_data("YouTube", result);
DIALData *readBack = retrieve_dial_data("YouTube");
for (int i = 0; readBack != NULL; readBack = readBack->next, i++) {
EXPECT_STREQ(readBack->key, keys[i]);
EXPECT_STREQ(readBack->value, values[i]);
}
DONE();
}