Public Access
IRC App: Alt scrolls, Up/Down recall sent lines; /j for /join
- Alt + ; / Alt + . scroll the Buffer back and forward - Up / Down (Fn + ; / Fn + .) browse the last 30 sent lines, shell-style, returning to the draft past the newest (InputHistory, host-tested) - /j is short for /join Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
#include <unity.h>
|
||||
|
||||
#include "input_history.h"
|
||||
|
||||
using namespace roro;
|
||||
|
||||
void setUp() {}
|
||||
void tearDown() {}
|
||||
|
||||
void test_up_brings_back_previous_lines_newest_first() {
|
||||
InputHistory h(10);
|
||||
h.add("one");
|
||||
h.add("two");
|
||||
std::string line;
|
||||
TEST_ASSERT_TRUE(h.up("", line));
|
||||
TEST_ASSERT_EQUAL_STRING("two", line.c_str());
|
||||
TEST_ASSERT_TRUE(h.up("two", line));
|
||||
TEST_ASSERT_EQUAL_STRING("one", line.c_str());
|
||||
TEST_ASSERT_FALSE(h.up("one", line)); // nothing older
|
||||
}
|
||||
|
||||
void test_down_returns_to_the_draft_being_typed() {
|
||||
InputHistory h(10);
|
||||
h.add("one");
|
||||
std::string line;
|
||||
h.up("half typed", line);
|
||||
TEST_ASSERT_TRUE(h.down(line));
|
||||
TEST_ASSERT_EQUAL_STRING("half typed", line.c_str());
|
||||
TEST_ASSERT_FALSE(h.down(line)); // already at the draft
|
||||
}
|
||||
|
||||
void test_adding_resets_browsing_and_skips_repeats_and_empty_lines() {
|
||||
InputHistory h(10);
|
||||
h.add("same");
|
||||
h.add("same");
|
||||
h.add("");
|
||||
std::string line;
|
||||
h.up("", line);
|
||||
TEST_ASSERT_FALSE(h.up(line, line)); // only one entry kept
|
||||
h.add("next");
|
||||
TEST_ASSERT_TRUE(h.up("", line));
|
||||
TEST_ASSERT_EQUAL_STRING("next", line.c_str());
|
||||
}
|
||||
|
||||
void test_keeps_only_the_most_recent_lines() {
|
||||
InputHistory h(2);
|
||||
h.add("a");
|
||||
h.add("b");
|
||||
h.add("c");
|
||||
std::string line;
|
||||
h.up("", line);
|
||||
h.up(line, line);
|
||||
TEST_ASSERT_EQUAL_STRING("b", line.c_str());
|
||||
TEST_ASSERT_FALSE(h.up(line, line));
|
||||
}
|
||||
|
||||
void test_empty_history_does_nothing() {
|
||||
InputHistory h(5);
|
||||
std::string line = "draft";
|
||||
TEST_ASSERT_FALSE(h.up("draft", line));
|
||||
TEST_ASSERT_FALSE(h.down(line));
|
||||
TEST_ASSERT_EQUAL_STRING("draft", line.c_str());
|
||||
}
|
||||
|
||||
int main() {
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_up_brings_back_previous_lines_newest_first);
|
||||
RUN_TEST(test_down_returns_to_the_draft_being_typed);
|
||||
RUN_TEST(test_adding_resets_browsing_and_skips_repeats_and_empty_lines);
|
||||
RUN_TEST(test_keeps_only_the_most_recent_lines);
|
||||
RUN_TEST(test_empty_history_does_nothing);
|
||||
return UNITY_END();
|
||||
}
|
||||
@@ -366,6 +366,16 @@ void test_input_message_and_commands() {
|
||||
TEST_ASSERT_EQUAL_STRING("/not a command", f.session->buffer(b).lines.back().text.c_str());
|
||||
}
|
||||
|
||||
void test_j_is_short_for_join() {
|
||||
Fixture f;
|
||||
f.registerNow();
|
||||
f.session->input(0, "/j #short", 0);
|
||||
f.session->input(0, "/j #locked k3y", 0);
|
||||
f.take();
|
||||
TEST_ASSERT_TRUE(f.sent("JOIN #short"));
|
||||
TEST_ASSERT_TRUE(f.sent("JOIN #locked k3y"));
|
||||
}
|
||||
|
||||
void test_msg_opens_a_query_buffer() {
|
||||
Fixture f;
|
||||
f.registerNow();
|
||||
@@ -483,6 +493,7 @@ int main() {
|
||||
RUN_TEST(test_action_and_ctcp_version);
|
||||
RUN_TEST(test_topic_is_kept);
|
||||
RUN_TEST(test_input_message_and_commands);
|
||||
RUN_TEST(test_j_is_short_for_join);
|
||||
RUN_TEST(test_msg_opens_a_query_buffer);
|
||||
RUN_TEST(test_text_in_the_server_buffer_explains_instead_of_sending);
|
||||
RUN_TEST(test_quit_sends_and_is_remembered);
|
||||
|
||||
Reference in New Issue
Block a user