diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-08-29 10:22:17 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-08-29 10:22:17 +0200 |
commit | 8b3311860b0825008e4d2c4bddc3978128d4cb13 (patch) | |
tree | d3664eb7aaa56ac31ad6c482498c84c718145b71 /tests | |
parent | 58d61cb153761979e162cd80162bac941797c40e (diff) | |
download | weechat-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.cpp | 28 |
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); } /* |