tests: add gmio_string_trim_from_end() to utils

This commit is contained in:
Hugues Delorme 2015-09-11 16:35:34 +02:00
parent 287ad5c13f
commit 4bde8be51f
2 changed files with 17 additions and 0 deletions

View File

@ -40,3 +40,16 @@ uint32_t gmio_float32_ulp_diff(gmio_float32_t a, gmio_float32_t b)
const uint32_t ub = gmio_convert_uint32(b);
return ua > ub ? ua - ub : ub - ua;
}
void gmio_string_trim_from_end(char *str, size_t len)
{
if (len > 0) {
do {
--len;
if (str[len] == 0 || gmio_clocale_isspace(str[len]))
str[len] = 0;
else
break;
} while (len != 0);
}
}

View File

@ -17,6 +17,7 @@
#define GMIO_TESTS_UTILS_H
#include "../src/gmio_core/global.h"
#include "../src/gmio_core/internal/string_utils.h"
#include "../src/gmio_core/internal/convert.h"
/*! Does \p a and \p b compares equals by ULP (Units in the Last Place) ?
@ -44,4 +45,7 @@ GMIO_INLINE int gmio_float32_sign(gmio_float32_t v)
return gmio_int32_sign(gmio_convert_int32(v));
}
/*! Trim whitespaces in string \p str from end */
void gmio_string_trim_from_end(char* str, size_t len);
#endif /* GMIO_TESTS_UTILS_H */