Browse Source

feat(testing): Add KillRingManager unit tests and fix previous() logic

Bernardo Magri 1 tháng trước cách đây
mục cha
commit
aaed7e56e7
2 tập tin đã thay đổi với 5 bổ sung4 xóa
  1. 4 4
      src/kill_ring_manager.cpp
  2. 1 0
      tests/CMakeLists.txt

+ 4 - 4
src/kill_ring_manager.cpp

@@ -39,10 +39,10 @@ std::string KillRingManager::previous() {
         return "";
     }
     
-    // Rotate the ring: move front to back
-    std::string front_item = ring_.front();
-    ring_.pop_front();
-    ring_.push_back(front_item);
+    // Rotate the ring: move back to front (conceptual 'previous')
+    std::string back_item = ring_.back();
+    ring_.pop_back();
+    ring_.push_front(back_item);
 
     last_action_was_kill_ = false; // Reset state for push logic
     return ring_.front();

+ 1 - 0
tests/CMakeLists.txt

@@ -18,6 +18,7 @@ add_executable(test_runner
     test_input_pipeline.cpp
     test_buffer_manager.cpp
     test_window_manager.cpp
+    test_kill_ring_manager.cpp
 )
 
 target_link_libraries(test_runner PRIVATE