1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 05:46:38 +02:00

tests: add tests on typing plugin functions

This commit is contained in:
Sébastien Helleu
2021-07-04 11:38:45 +02:00
parent 8dc75564c2
commit 7c83ee02f2
10 changed files with 532 additions and 216 deletions
+24 -21
View File
@@ -53,6 +53,9 @@ typing_status_search_state (const char *state)
{
int i;
if (!state)
return -1;
for (i = 0; i < TYPING_STATUS_NUM_STATES; i++)
{
if (strcmp (typing_status_state_string[i], state) == 0)
@@ -297,6 +300,27 @@ typing_status_nick_add (struct t_gui_buffer *buffer, const char *nick,
return ptr_typing_status;
}
/*
* Searches a nick typing status for a buffer.
*
* Returns pointer to t_typing_status found, NULL if not found.
*/
struct t_typing_status *
typing_status_nick_search (struct t_gui_buffer *buffer, const char *nick)
{
struct t_hashtable *ptr_nicks;
if (!typing_status_nicks || !buffer || !nick)
return NULL;
ptr_nicks = weechat_hashtable_get (typing_status_nicks, buffer);
if (!ptr_nicks)
return NULL;
return weechat_hashtable_get (ptr_nicks, nick);
}
/*
* Removes a nick typing status from a buffer.
*
@@ -320,27 +344,6 @@ typing_status_nick_remove (struct t_gui_buffer *buffer, const char *nick)
weechat_hashtable_remove (ptr_nicks, nick);
}
/*
* Searches a nick typing status for a buffer.
*
* Returns pointer to t_typing_status found, NULL if not found.
*/
struct t_typing_status *
typing_status_nick_search (struct t_gui_buffer *buffer, const char *nick)
{
struct t_hashtable *ptr_nicks;
if (!typing_status_nicks)
return NULL;
ptr_nicks = weechat_hashtable_get (typing_status_nicks, buffer);
if (!ptr_nicks)
return NULL;
return weechat_hashtable_get (ptr_nicks, nick);
}
/*
* Ends typing status.
*/
+3 -2
View File
@@ -40,6 +40,7 @@ struct t_typing_status
time_t last_typed; /* when was last char typed */
};
extern char *typing_status_state_string[];
extern struct t_hashtable *typing_status_self;
extern struct t_hashtable *typing_status_nicks;
@@ -52,10 +53,10 @@ extern struct t_typing_status *typing_status_nick_add (struct t_gui_buffer *buff
const char *nick,
int state,
int last_typed);
extern void typing_status_nick_remove (struct t_gui_buffer *buffer,
const char *nick);
extern struct t_typing_status *typing_status_nick_search (struct t_gui_buffer *buffer,
const char *nick);
extern void typing_status_nick_remove (struct t_gui_buffer *buffer,
const char *nick);
extern void typing_status_end ();
#endif /* WEECHAT_PLUGIN_TYPING_STATUS_H */