summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-08-29 10:22:17 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-08-29 10:22:17 +0200
commit8b3311860b0825008e4d2c4bddc3978128d4cb13 (patch)
treed3664eb7aaa56ac31ad6c482498c84c718145b71 /tests
parent58d61cb153761979e162cd80162bac941797c40e (diff)
downloadweechat-8b3311860b0825008e4d2c4bddc3978128d4cb13.zip
api: add support of path to variable and hashtable comparison in function hdata_compare (closes #1066)
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/core/test-core-hdata.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/unit/core/test-core-hdata.cpp b/tests/unit/core/test-core-hdata.cpp
index 40a874818..a4054f4d2 100644
--- a/tests/unit/core/test-core-hdata.cpp
+++ b/tests/unit/core/test-core-hdata.cpp
@@ -2048,6 +2048,9 @@ TEST(CoreHdataWithList, Hashtable)
TEST(CoreHdataWithList, Compare)
{
+ struct t_gui_buffer *test_buffer;
+ struct t_hdata *ptr_hdata_buffer;
+
LONGS_EQUAL(0, hdata_compare (NULL, NULL, NULL, NULL, 0));
LONGS_EQUAL(0, hdata_compare (ptr_hdata, NULL, NULL, NULL, 0));
@@ -2114,13 +2117,32 @@ TEST(CoreHdataWithList, Compare)
LONGS_EQUAL(1, hdata_compare (ptr_hdata, ptr_item2, ptr_item1,
"test_time", 0));
- /* compare hashtables: not possible */
- LONGS_EQUAL(0, hdata_compare (ptr_hdata, ptr_item1, ptr_item2,
- "test_hashtable", 0));
+ /* compare hashtables: pointer comparison */
+ CHECK(hdata_compare (ptr_hdata, ptr_item1, ptr_item2,
+ "test_hashtable", 0) != 0);
/* compare "other" type: not possible */
LONGS_EQUAL(0, hdata_compare (ptr_hdata, ptr_item1, ptr_item2,
"test_other", 0));
+
+ /* create a test buffer */
+ test_buffer = gui_buffer_new (NULL, "test",
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
+ CHECK(test_buffer);
+ ptr_hdata_buffer = hook_hdata_get (NULL, "buffer");
+
+ /* compare two sub-fields of buffers: test recursive path traversal */
+ LONGS_EQUAL(1, hdata_compare (ptr_hdata_buffer, gui_buffers, test_buffer,
+ "own_lines.lines_count", 0));
+ gui_buffer_set (gui_buffers, "localvar_set_myvar", "def");
+ gui_buffer_set (test_buffer, "localvar_set_myvar", "abc");
+ CHECK(ptr_hdata_buffer);
+ LONGS_EQUAL(1, hdata_compare (ptr_hdata_buffer, gui_buffers, test_buffer,
+ "local_variables.myvar", 0));
+ gui_buffer_set (gui_buffers, "localvar_del_myvar", "");
+
+ gui_buffer_close (test_buffer);
}
/*