aboutsummaryrefslogtreecommitdiffhomepage
path: root/fish_tests.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-07-25 10:08:21 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-07-25 10:49:12 -0700
commite9f870e25af2fb8bf2dfbf5c92faaff667fd4cc1 (patch)
tree9ff028b8fc75082a7b5a605ea04cbef8036a73b2 /fish_tests.cpp
parent317660c2fe71dbbb31c85aa313f669f55c2f8df7 (diff)
Add support for history --merge to incorporate history changes from
other sessions. Fixes #825
Diffstat (limited to 'fish_tests.cpp')
-rw-r--r--fish_tests.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/fish_tests.cpp b/fish_tests.cpp
index b29f7124..6584380d 100644
--- a/fish_tests.cpp
+++ b/fish_tests.cpp
@@ -2688,7 +2688,8 @@ void history_tests_t::test_history_merge(void)
const size_t count = 3;
const wcstring name = L"merge_test";
history_t *hists[count] = {new history_t(name), new history_t(name), new history_t(name)};
- wcstring texts[count] = {L"History 1", L"History 2", L"History 3"};
+ const wcstring texts[count] = {L"History 1", L"History 2", L"History 3"};
+ const wcstring alt_texts[count] = {L"History Alt 1", L"History Alt 2", L"History Alt 3"};
/* Make sure history is clear */
for (size_t i=0; i < count; i++)
@@ -2730,6 +2731,32 @@ void history_tests_t::test_history_merge(void)
do_test(history_contains(everything, texts[i]));
}
+ /* Tell all histories to merge. Now everybody should have everything. */
+ for (size_t i=0; i < count; i++)
+ {
+ hists[i]->incorporate_external_changes();
+ }
+ /* Add some more per-history items */
+ for (size_t i=0; i < count; i++)
+ {
+ hists[i]->add(alt_texts[i]);
+ }
+ /* Everybody should have old items, but only one history should have each new item */
+ for (size_t i = 0; i < count; i++)
+ {
+ for (size_t j=0; j < count; j++)
+ {
+ /* Old item */
+ do_test(history_contains(hists[i], texts[j]));
+
+ /* New item */
+ bool does_contain = history_contains(hists[i], alt_texts[j]);
+ bool should_contain = (i == j);
+ do_test(should_contain == does_contain);
+ }
+ }
+
+
/* Clean up */
for (size_t i=0; i < 3; i++)
{