Started work on bash style history

This commit is contained in:
James Booth
2012-04-30 01:09:42 +01:00
parent c511d7c99f
commit b6c5fef45e
7 changed files with 161 additions and 3 deletions

49
test_prof_history.c Normal file
View File

@@ -0,0 +1,49 @@
#include <stdio.h>
#include <head-unit.h>
#include "prof_history.h"
void previous_on_empty_returns_null(void)
{
PHistory history = p_history_new(10);
char *item = p_history_previous(history);
assert_is_null(item);
}
void next_on_empty_returns_null(void)
{
PHistory history = p_history_new(10);
char *item = p_history_next(history);
assert_is_null(item);
}
void previous_once_returns_last(void)
{
PHistory history = p_history_new(10);
p_history_append(history, "Hello");
char *item = p_history_previous(history);
assert_string_equals("Hello", item);
}
void previous_twice_when_one_returns_first(void)
{
PHistory history = p_history_new(10);
p_history_append(history, "Hello");
p_history_previous(history);
char *item = p_history_previous(history);
assert_string_equals("Hello", item);
}
void register_prof_history_tests(void)
{
TEST_MODULE("prof_history tests");
TEST(previous_on_empty_returns_null);
TEST(next_on_empty_returns_null);
TEST(previous_once_returns_last);
TEST(previous_twice_when_one_returns_first);
}