From a1035cf81494c3ab22c49b01788ca8ad933c5eb0 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 26 Aug 2018 09:42:08 +0000 Subject: Add some tests for `ping_array`. No timeout test here yet, because we don't yet have the ability to manipulate time at will, so we would have to actually sleep. --- toxcore/ping_array.h | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'toxcore/ping_array.h') diff --git a/toxcore/ping_array.h b/toxcore/ping_array.h index cfa9bfcc..7bc95a42 100644 --- a/toxcore/ping_array.h +++ b/toxcore/ping_array.h @@ -21,10 +21,15 @@ * You should have received a copy of the GNU General Public License * along with Tox. If not, see . */ -#ifndef PING_ARRAY_H -#define PING_ARRAY_H +#ifndef C_TOXCORE_TOXCORE_PING_ARRAY_H +#define C_TOXCORE_TOXCORE_PING_ARRAY_H -#include "network.h" +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif #ifndef MONO_TIME_DEFINED #define MONO_TIME_DEFINED @@ -38,11 +43,11 @@ typedef struct Ping_Array Ping_Array; /** * Initialize a Ping_Array. - * size represents the total size of the array and should be a power of 2. - * timeout represents the maximum timeout in seconds for the entry. * - * return 0 on success. - * return -1 on failure. + * @param size represents the total size of the array and should be a power of 2. + * @param timeout represents the maximum timeout in seconds for the entry. + * + * @return 0 on success, -1 on failure. */ struct Ping_Array *ping_array_new(uint32_t size, uint32_t timeout); @@ -54,8 +59,7 @@ void ping_array_kill(struct Ping_Array *_array); /** * Add a data with length to the Ping_Array list and return a ping_id. * - * return ping_id on success. - * return 0 on failure. + * @return ping_id on success, 0 on failure. */ uint64_t ping_array_add(struct Ping_Array *_array, const struct Mono_Time *mono_time, const uint8_t *data, uint32_t length); @@ -65,10 +69,13 @@ uint64_t ping_array_add(struct Ping_Array *_array, const struct Mono_Time *mono_ * * On success, copies the data into data of length, * - * return length of data copied on success. - * return -1 on failure. + * @return length of data copied on success, -1 on failure. */ int32_t ping_array_check(struct Ping_Array *_array, const struct Mono_Time *mono_time, uint8_t *data, size_t length, uint64_t ping_id); +#ifdef __cplusplus +} // extern "C" #endif + +#endif // C_TOXCORE_TOXCORE_PING_ARRAY_H -- cgit v1.2.3