about summary refs log tree commit diff stats
path: root/test_prof_history.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-04-30 01:09:42 +0100
committerJames Booth <boothj5@gmail.com>2012-04-30 01:09:42 +0100
commitb6c5fef45eaadce4463ee60e60eb0a0252b61255 (patch)
tree2ddb6ce1f874413648a7dcd74fb03f7c41ec95da /test_prof_history.c
parentc511d7c99f792823fd2727d3a5a1f1fd722b8a33 (diff)
downloadprofani-tty-b6c5fef45eaadce4463ee60e60eb0a0252b61255.tar.gz
Started work on bash style history
Diffstat (limited to 'test_prof_history.c')
-rw-r--r--test_prof_history.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/test_prof_history.c b/test_prof_history.c
new file mode 100644
index 00000000..5a9ae217
--- /dev/null
+++ b/test_prof_history.c
@@ -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);
+}