summaryrefslogtreecommitdiff
path: root/tests/unit/gui
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2019-11-25 23:02:05 +0100
committerSébastien Helleu <flashcode@flashtux.org>2019-11-25 23:02:05 +0100
commit3dab07d65955cf61ec5add3a6ab9ae3112b8a897 (patch)
treeb2ad85867d949c943e355e8feddd6407b437289b /tests/unit/gui
parentcd53fc61cfd89158201adc6b0e1912fb1a3e7f56 (diff)
downloadweechat-3dab07d65955cf61ec5add3a6ab9ae3112b8a897.zip
tests: add unit tests on hash algorithms with salt (issue #635)
Diffstat (limited to 'tests/unit/gui')
-rw-r--r--tests/unit/gui/test-gui-nick.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/gui/test-gui-nick.cpp b/tests/unit/gui/test-gui-nick.cpp
index fbf8cf425..e92ce744d 100644
--- a/tests/unit/gui/test-gui-nick.cpp
+++ b/tests/unit/gui/test-gui-nick.cpp
@@ -58,6 +58,8 @@ TEST(GuiNick, NickHashColor)
{
config_file_option_set (config_color_chat_nick_colors, NICK_COLORS, 0);
+ /* hash without salt */
+
/* test hash: djb2 */
config_file_option_set (config_look_nick_color_hash, "djb2", 0);
@@ -118,5 +120,27 @@ TEST(GuiNick, NickHashColor)
"abcdefghijklmnopqrstuvwxyz"));
LONGS_EQUAL(220, gui_nick_hash_color ("zzzzzz"));
+ /* hash with salt */
+
+ config_file_option_set (config_look_nick_color_hash_salt, "abc", 0);
+
+ /* test hash: djb2 */
+ config_file_option_set (config_look_nick_color_hash, "djb2", 0);
+ LONGS_EQUAL(146, gui_nick_hash_color ("def"));
+
+ /* test hash: sum */
+ config_file_option_set (config_look_nick_color_hash, "sum", 0);
+ LONGS_EQUAL(85, gui_nick_hash_color ("def"));
+
+ /* test hash: djb2_32 */
+ config_file_option_set (config_look_nick_color_hash, "djb2_32", 0);
+ LONGS_EQUAL(146, gui_nick_hash_color ("def"));
+
+ /* test hash: sum_32 */
+ config_file_option_set (config_look_nick_color_hash, "sum_32", 0);
+ LONGS_EQUAL(85, gui_nick_hash_color ("def"));
+
+ config_file_option_reset (config_look_nick_color_hash_salt, 0);
+
config_file_option_reset (config_color_chat_nick_colors, 0);
}