* api: add info "uptime_current"
* api: add function crypto_hash_file
* api: add support of priority in function hook_line (issue #1821)
+ * api: add function string_parse_size
* buflist: add variable `${hotlist_priority_number}` (integer version of `${hotlist_priority}`)
* irc: display SETNAME command in channels and private buffers, add options irc.color.message_setname and irc.look.smart_filter_setname (issue #1805)
* irc: add option irc.look.display_pv_nick_change
string_has_highlight_regex +
string_mask_to_regex +
string_format_size +
+ string_parse_size +
string_color_code_size +
string_remove_color +
string_is_command_char +
str = weechat.string_format_size(15200) # == "15.2 KB"
----
+==== string_parse_size
+
+_WeeChat ≥ 3.7._
+
+Parse a string with a size and optional unit and return the size in bytes.
+
+Prototype:
+
+[source,c]
+----
+unsigned long long weechat_string_parse_size (const char *size);
+----
+
+Arguments:
+
+* _size_: the size as string: float number followed optional spaces and optional
+ unit (lower or upper case), which is one of:
+** _b_: bytes
+** _k_: kilobytes (1k = 1000 bytes)
+** _m_: megabytes (1m = 1000k = 1,000,000 bytes)
+** _g_: gigabytes (1g = 1000m = 1,000,000,000 bytes)
+** _t_: terabytes (1t = 1000g = 1,000,000,000,000 bytes)
+
+Return value:
+
+* size in bytes, 0 if error
+
+C example:
+
+[source,c]
+----
+unsigned long long size = weechat_parse_size ("1.34m"); /* size == 1340000 */
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototype
+def string_parse_size(size: str) -> int: ...
+
+# example
+size = weechat.string_parse_size("1.34m") # 1340000
+----
+
==== string_color_code_size
_WeeChat ≥ 3.0._
string_has_highlight_regex +
string_mask_to_regex +
string_format_size +
+ string_parse_size +
string_color_code_size +
string_remove_color +
string_is_command_char +
str = weechat.string_format_size(15200) # == "15.2 Ko"
----
+==== string_parse_size
+
+_WeeChat ≥ 3.7._
+
+Analyser une chaîne avec une taille et une unité optionnelle et retourner
+la taille en octets.
+
+Prototype :
+
+[source,c]
+----
+unsigned long long weechat_string_parse_size (const char *size);
+----
+
+Paramètres :
+
+* _size_ : la taille sous forme de chaîne : nombre décimal suivi par des espaces
+ optionnels et une unité optionnelle (en minuscules ou majuscules), qui est une
+ des suivantes :
+** _b_ : octets
+** _k_ : kilo-octets (1k = 1000 octets)
+** _m_ : méga-octets (1m = 1000k = 1 000 000 octets)
+** _g_ : giga-octets (1g = 1000m = 1 000 000 000 octets)
+** _t_ : tera-octets (1t = 1000g = 1 000 000 000 000 octets)
+
+Valeur de retour :
+
+* taille en octets, 0 si erreur
+
+Exemple en C :
+
+[source,c]
+----
+unsigned long long size = weechat_parse_size ("1.34m"); /* size == 1340000 */
+----
+
+Script (Python) :
+
+[source,python]
+----
+# prototype
+def string_parse_size(size: str) -> int: ...
+
+# exemple
+size = weechat.string_parse_size("1.34m") # 1340000
+----
+
==== string_color_code_size
_WeeChat ≥ 3.0._
string_has_highlight_regex +
string_mask_to_regex +
string_format_size +
+ string_parse_size +
string_color_code_size +
string_remove_color +
string_is_command_char +
str = weechat.string_format_size(15200) # == "15.2 KB"
----
+// TRANSLATION MISSING
+==== string_parse_size
+
+_WeeChat ≥ 3.7._
+
+Parse a string with a size and optional unit and return the size in bytes.
+
+Prototipo:
+
+[source,c]
+----
+unsigned long long weechat_string_parse_size (const char *size);
+----
+
+Argomenti:
+
+* _size_: the size as string: float number followed optional spaces and optional
+ unit (lower or upper case), which is one of:
+** _b_: bytes
+** _k_: kilobytes (1k = 1000 bytes)
+** _m_: megabytes (1m = 1000k = 1,000,000 bytes)
+** _g_: gigabytes (1g = 1000m = 1,000,000,000 bytes)
+** _t_: terabytes (1t = 1000g = 1,000,000,000,000 bytes)
+
+Valore restituito:
+
+* size in bytes, 0 if error
+
+Esempio in C:
+
+[source,c]
+----
+unsigned long long size = weechat_parse_size ("1.34m"); /* size == 1340000 */
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototipo
+def string_parse_size(size: str) -> int: ...
+
+# esempio
+size = weechat.string_parse_size("1.34m") # 1340000
+----
+
==== string_color_code_size
_WeeChat ≥ 3.0._
string_has_highlight_regex +
string_mask_to_regex +
string_format_size +
+ string_parse_size +
string_color_code_size +
string_remove_color +
string_is_command_char +
str = weechat.string_format_size(15200) # == "15.2 KB"
----
+// TRANSLATION MISSING
+==== string_parse_size
+
+_WeeChat ≥ 3.7._
+
+Parse a string with a size and optional unit and return the size in bytes.
+
+プロトタイプ:
+
+[source,c]
+----
+unsigned long long weechat_string_parse_size (const char *size);
+----
+
+引数:
+
+* _size_: the size as string: float number followed optional spaces and optional
+ unit (lower or upper case), which is one of:
+** _b_: bytes
+** _k_: kilobytes (1k = 1000 bytes)
+** _m_: megabytes (1m = 1000k = 1,000,000 bytes)
+** _g_: gigabytes (1g = 1000m = 1,000,000,000 bytes)
+** _t_: terabytes (1t = 1000g = 1,000,000,000,000 bytes)
+
+戻り値:
+
+* size in bytes, 0 if error
+
+C 言語での使用例:
+
+[source,c]
+----
+unsigned long long size = weechat_parse_size ("1.34m"); /* size == 1340000 */
+----
+
+Script (Python):
+
+[source,python]
+----
+# プロトタイプ
+def string_parse_size(size: str) -> int: ...
+
+# 例
+size = weechat.string_parse_size("1.34m") # 1340000
+----
+
==== string_color_code_size
_WeeChat ≥ 3.0._
string_has_highlight_regex +
string_mask_to_regex +
string_format_size +
+ string_parse_size +
string_color_code_size +
string_remove_color +
string_is_command_char +
string_has_highlight_regex +
string_mask_to_regex +
string_format_size +
+ string_parse_size +
string_color_code_size +
string_remove_color +
string_is_command_char +
str = weechat.string_format_size(15200) # == "15.2 KB"
----
+// TRANSLATION MISSING
+==== string_parse_size
+
+_WeeChat ≥ 3.7._
+
+Parse a string with a size and optional unit and return the size in bytes.
+
+Прототип:
+
+[source,c]
+----
+unsigned long long weechat_string_parse_size (const char *size);
+----
+
+Аргументи:
+
+* _size_: the size as string: float number followed optional spaces and optional
+ unit (lower or upper case), which is one of:
+** _b_: bytes
+** _k_: kilobytes (1k = 1000 bytes)
+** _m_: megabytes (1m = 1000k = 1,000,000 bytes)
+** _g_: gigabytes (1g = 1000m = 1,000,000,000 bytes)
+** _t_: terabytes (1t = 1000g = 1,000,000,000,000 bytes)
+
+Повратна вредност:
+
+* size in bytes, 0 if error
+
+C пример:
+
+[source,c]
+----
+unsigned long long size = weechat_parse_size ("1.34m"); /* size == 1340000 */
+----
+
+Script (Python):
+
+[source,python]
+----
+# прототип
+def string_parse_size(size: str) -> int: ...
+
+# пример
+size = weechat.string_parse_size("1.34m") # 1340000
+----
+
==== string_color_code_size
_WeeChat ≥ 3.0._
string_has_highlight_regex +
string_mask_to_regex +
string_format_size +
+ string_parse_size +
string_color_code_size +
string_remove_color +
string_is_command_char +
return strdup (str_size);
}
+/*
+ * Parses a string with a size and returns the size in bytes.
+ *
+ * The format is "123" or "123X" or "123 X" where 123 is any positive number
+ * as a float (for example: 123 or 4.56) and X the unit, which can be one of
+ * (lower or upper case are accepted):
+ *
+ * b bytes (default if unit is missing)
+ * k kilobytes (1k = 1000 bytes)
+ * m megabytes (1m = 1000k = 1,000,000 bytes)
+ * g gigabytes (1g = 1000m = 1,000,000,000 bytes)
+ * t terabytes (1t = 1000g = 1,000,000,000,000 bytes)
+ *
+ * Note: decimals of the float number are ignored if the unit is bytes
+ * (eg: "5.9" or "5.9B" returns 5).
+ *
+ * Returns the parsed size, 0 if error.
+ */
+
+unsigned long long
+string_parse_size (const char *size)
+{
+ const char *pos;
+ char *str_number, *error;
+ double number;
+ unsigned long long result;
+
+ str_number = NULL;
+ result = 0;
+
+ if (!size || !size[0])
+ goto end;
+
+ pos = size;
+ while ((pos[0] == '.') || isdigit (pos[0]))
+ {
+ pos++;
+ }
+
+ if (pos == size)
+ goto end;
+
+ str_number = string_strndup (size, pos - size);
+ if (!str_number)
+ goto end;
+
+ number = strtod (str_number, &error);
+ if (!error || error[0])
+ goto end;
+
+ while (pos[0] == ' ')
+ {
+ pos++;
+ }
+
+ if (pos[0] && pos[1])
+ goto end;
+
+ switch (pos[0])
+ {
+ case '\0':
+ result = number;
+ break;
+ case 'b':
+ case 'B':
+ result = number;
+ break;
+ case 'k':
+ case 'K':
+ result = number * 1000.0;
+ break;
+ case 'm':
+ case 'M':
+ result = number * 1000.0 * 1000.0;
+ break;
+ case 'g':
+ case 'G':
+ result = number * 1000.0 * 1000.0 * 1000.0;
+ break;
+ case 't':
+ case 'T':
+ result = number * 1000.0 * 1000.0 * 1000.0 * 1000.0;
+ break;
+ }
+
+end:
+ if (str_number)
+ free (str_number);
+ return result;
+}
+
/*
* Encodes a string in base16 (hexadecimal).
*
const char *string);
extern int string_fprintf (FILE *file, const char *data, ...);
extern char *string_format_size (unsigned long long size);
+extern unsigned long long string_parse_size (const char *size);
extern int string_base16_encode (const char *from, int length, char *to);
extern int string_base16_decode (const char *from, char *to);
extern int string_base32_encode (const char *from, int length, char *to);
API_RETURN_STRING_FREE(result);
}
+SCM
+weechat_guile_api_string_parse_size (SCM size)
+{
+ unsigned long long value;
+
+ API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
+ if (!scm_is_string (size))
+ API_WRONG_ARGS(API_RETURN_LONG(0));
+
+ value = weechat_string_parse_size (API_SCM_TO_STRING(size));
+
+ API_RETURN_LONG(value);
+}
+
SCM
weechat_guile_api_string_color_code_size (SCM string)
{
API_DEF_FUNC(string_has_highlight_regex, 2);
API_DEF_FUNC(string_mask_to_regex, 1);
API_DEF_FUNC(string_format_size, 1);
+ API_DEF_FUNC(string_parse_size, 1);
API_DEF_FUNC(string_color_code_size, 1);
API_DEF_FUNC(string_remove_color, 2);
API_DEF_FUNC(string_is_command_char, 1);
API_RETURN_STRING_FREE(result);
}
+API_FUNC(string_parse_size)
+{
+ unsigned long long value;
+
+ API_INIT_FUNC(1, "string_parse_size", "s", API_RETURN_LONG(0));
+
+ v8::String::Utf8Value size(args[0]);
+
+ value = weechat_string_parse_size (*size);
+
+ API_RETURN_LONG(value);
+}
+
API_FUNC(string_color_code_size)
{
int size;
API_DEF_FUNC(string_has_highlight_regex);
API_DEF_FUNC(string_mask_to_regex);
API_DEF_FUNC(string_format_size);
+ API_DEF_FUNC(string_parse_size);
API_DEF_FUNC(string_color_code_size);
API_DEF_FUNC(string_remove_color);
API_DEF_FUNC(string_is_command_char);
API_RETURN_STRING_FREE(result);
}
+API_FUNC(string_parse_size)
+{
+ const char *size;
+ unsigned long long value;
+
+ API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
+ if (lua_gettop (L) < 1)
+ API_WRONG_ARGS(API_RETURN_LONG(0));
+
+ size = lua_tostring (L, -1);
+
+ value = weechat_string_parse_size (size);
+
+ API_RETURN_LONG(value);
+}
+
API_FUNC(string_color_code_size)
{
const char *string;
API_DEF_FUNC(string_has_highlight_regex),
API_DEF_FUNC(string_mask_to_regex),
API_DEF_FUNC(string_format_size),
+ API_DEF_FUNC(string_parse_size),
API_DEF_FUNC(string_color_code_size),
API_DEF_FUNC(string_remove_color),
API_DEF_FUNC(string_is_command_char),
API_RETURN_STRING_FREE(result);
}
+API_FUNC(string_parse_size)
+{
+ unsigned long long value;
+ dXSARGS;
+
+ API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
+ if (items < 1)
+ API_WRONG_ARGS(API_RETURN_LONG(0));
+
+ value = weechat_string_parse_size (SvPV_nolen (ST (0))); /* size */
+
+ API_RETURN_LONG(value);
+}
+
API_FUNC(string_color_code_size)
{
int size;
API_DEF_FUNC(string_has_highlight_regex);
API_DEF_FUNC(string_mask_to_regex);
API_DEF_FUNC(string_format_size);
+ API_DEF_FUNC(string_parse_size);
API_DEF_FUNC(string_color_code_size);
API_DEF_FUNC(string_remove_color);
API_DEF_FUNC(string_is_command_char);
API_RETURN_STRING_FREE(result);
}
+API_FUNC(string_parse_size)
+{
+ zend_string *z_size;
+ char *size;
+ unsigned long long value;
+
+ API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
+ if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_size) == FAILURE)
+ API_WRONG_ARGS(API_RETURN_LONG(0));
+
+ size = ZSTR_VAL(z_size);
+
+ value = weechat_string_parse_size ((const char *)size);
+
+ API_RETURN_LONG(value);
+}
+
API_FUNC(string_color_code_size)
{
zend_string *z_string;
PHP_FUNCTION(weechat_string_has_highlight_regex);
PHP_FUNCTION(weechat_string_mask_to_regex);
PHP_FUNCTION(weechat_string_format_size);
+PHP_FUNCTION(weechat_string_parse_size);
PHP_FUNCTION(weechat_string_color_code_size);
PHP_FUNCTION(weechat_string_remove_color);
PHP_FUNCTION(weechat_string_is_command_char);
PHP_FE(weechat_string_has_highlight_regex, arginfo_weechat_string_has_highlight_regex)
PHP_FE(weechat_string_mask_to_regex, arginfo_weechat_string_mask_to_regex)
PHP_FE(weechat_string_format_size, arginfo_weechat_string_format_size)
+ PHP_FE(weechat_string_parse_size, arginfo_weechat_string_parse_size)
PHP_FE(weechat_string_color_code_size, arginfo_weechat_string_color_code_size)
PHP_FE(weechat_string_remove_color, arginfo_weechat_string_remove_color)
PHP_FE(weechat_string_is_command_char, arginfo_weechat_string_is_command_char)
function weechat_string_has_highlight_regex(string $p0, string $p1): int {}
function weechat_string_mask_to_regex(string $p0): string {}
function weechat_string_format_size(int $p0): string {}
+function weechat_string_parse_size(string $p0): int {}
function weechat_string_color_code_size(string $p0): int {}
function weechat_string_remove_color(string $p0, string $p1): string {}
function weechat_string_is_command_char(string $p0): int {}
ZEND_ARG_TYPE_INFO(0, p0, IS_LONG, 0)
ZEND_END_ARG_INFO()
+#define arginfo_weechat_string_parse_size arginfo_weechat_charset_set
+
#define arginfo_weechat_string_color_code_size arginfo_weechat_charset_set
#define arginfo_weechat_string_remove_color arginfo_weechat_iconv_to_internal
new_plugin->string_split_command = &string_split_command;
new_plugin->string_free_split_command = &string_free_split_command;
new_plugin->string_format_size = &string_format_size;
+ new_plugin->string_parse_size = &string_parse_size;
new_plugin->string_color_code_size = &gui_color_code_size;
new_plugin->string_remove_color = &gui_color_decode;
new_plugin->string_base_encode = &string_base_encode;
API_RETURN_STRING_FREE(result);
}
+API_FUNC(string_parse_size)
+{
+ char *size;
+ unsigned long long value;
+
+ API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
+ size = NULL;
+ if (!PyArg_ParseTuple (args, "s", &size))
+ API_WRONG_ARGS(API_RETURN_LONG(0));
+
+ value = weechat_string_parse_size (size);
+
+ API_RETURN_LONG(value);
+}
+
API_FUNC(string_color_code_size)
{
char *string;
API_DEF_FUNC(string_has_highlight_regex),
API_DEF_FUNC(string_mask_to_regex),
API_DEF_FUNC(string_format_size),
+ API_DEF_FUNC(string_parse_size),
API_DEF_FUNC(string_color_code_size),
API_DEF_FUNC(string_remove_color),
API_DEF_FUNC(string_is_command_char),
...
+def string_parse_size(size: str) -> int:
+ """`string_parse_size in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_parse_size>`_"""
+ ...
+
+
def string_color_code_size(string: str) -> int:
"""`string_color_code_size in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_color_code_size>`_"""
...
API_RETURN_STRING_FREE(result);
}
+static VALUE
+weechat_ruby_api_string_parse_size (VALUE class, VALUE size)
+{
+ char *c_size;
+ unsigned long long value;
+
+ API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
+ if (NIL_P (size))
+ API_WRONG_ARGS(API_RETURN_LONG(0));
+
+ Check_Type (size, T_STRING);
+
+ c_size = StringValuePtr (size);
+
+ value = weechat_string_parse_size (c_size);
+
+ API_RETURN_LONG(value);
+}
+
static VALUE
weechat_ruby_api_string_color_code_size (VALUE class, VALUE string)
{
API_DEF_FUNC(string_has_highlight_regex, 2);
API_DEF_FUNC(string_mask_to_regex, 1);
API_DEF_FUNC(string_format_size, 1);
+ API_DEF_FUNC(string_parse_size, 1);
API_DEF_FUNC(string_color_code_size, 1);
API_DEF_FUNC(string_remove_color, 2);
API_DEF_FUNC(string_is_command_char, 1);
API_RETURN_STRING_FREE(result);
}
+API_FUNC(string_parse_size)
+{
+ Tcl_Obj *objp;
+ char *size;
+ unsigned long long value;
+ int i;
+
+ API_INIT_FUNC(1, "string_parse_size", API_RETURN_LONG(0));
+ if (objc < 2)
+ API_WRONG_ARGS(API_RETURN_LONG(0));
+
+ size = Tcl_GetStringFromObj (objv[1], &i);
+
+ value = weechat_string_parse_size (size);
+
+ API_RETURN_LONG(value);
+}
+
API_FUNC(string_color_code_size)
{
Tcl_Obj *objp;
API_DEF_FUNC(string_has_highlight_regex);
API_DEF_FUNC(string_mask_to_regex);
API_DEF_FUNC(string_format_size);
+ API_DEF_FUNC(string_parse_size);
API_DEF_FUNC(string_color_code_size);
API_DEF_FUNC(string_remove_color);
API_DEF_FUNC(string_is_command_char);
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
-#define WEECHAT_PLUGIN_API_VERSION "20220816-01"
+#define WEECHAT_PLUGIN_API_VERSION "20220925-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
char **(*string_split_command) (const char *command, char separator);
void (*string_free_split_command) (char **split_command);
char *(*string_format_size) (unsigned long long size);
+ unsigned long long (*string_parse_size) (const char *size);
int (*string_color_code_size) (const char *string);
char *(*string_remove_color) (const char *string, const char *replacement);
int (*string_base_encode) (int base, const char *from, int length,
(weechat_plugin->string_free_split_command)(__split_command)
#define weechat_string_format_size(__size) \
(weechat_plugin->string_format_size)(__size)
+#define weechat_string_parse_size(__size) \
+ (weechat_plugin->string_parse_size)(__size)
#define weechat_string_color_code_size(__string) \
(weechat_plugin->string_color_code_size)(__string)
#define weechat_string_remove_color(__string, __replacement) \
check(weechat.string_format_size(1) == '1 byte')
check(weechat.string_format_size(2097152) == '2.10 MB')
check(weechat.string_format_size(420000000) == '420.00 MB')
+ check(weechat.string_parse_size('') == 0)
+ check(weechat.string_parse_size('*') == 0)
+ check(weechat.string_parse_size('z') == 0)
+ check(weechat.string_parse_size('1ba') == 0)
+ check(weechat.string_parse_size('1') == 1)
+ check(weechat.string_parse_size('12b') == 12)
+ check(weechat.string_parse_size('123 b') == 123)
+ check(weechat.string_parse_size('1.34k') == 1340)
+ check(weechat.string_parse_size('1.5m') == 1500000)
+ check(weechat.string_parse_size('2.1g') == 2100000000)
check(weechat.string_color_code_size('') == 0)
check(weechat.string_color_code_size('test') == 0)
str_color = weechat.color('yellow,red')
WEE_FORMAT_SIZE("42.00 TB", 42 * ONE_TB);
}
+/*
+ * Tests functions:
+ * string_parse_size
+ */
+
+TEST(CoreString, ParseSize)
+{
+ CHECK(string_parse_size (NULL) == 0ULL);
+
+ CHECK(string_parse_size ("") == 0ULL);
+ CHECK(string_parse_size ("*") == 0ULL);
+ CHECK(string_parse_size ("b") == 0ULL);
+ CHECK(string_parse_size ("k") == 0ULL);
+ CHECK(string_parse_size ("m") == 0ULL);
+ CHECK(string_parse_size ("g") == 0ULL);
+ CHECK(string_parse_size ("t") == 0ULL);
+ CHECK(string_parse_size ("z") == 0ULL);
+ CHECK(string_parse_size ("0z") == 0ULL);
+
+ CHECK(string_parse_size ("0") == 0ULL);
+ CHECK(string_parse_size ("0b") == 0ULL);
+ CHECK(string_parse_size ("0B") == 0ULL);
+
+ CHECK(string_parse_size ("1") == 1ULL);
+ CHECK(string_parse_size ("1b") == 1ULL);
+ CHECK(string_parse_size ("1B") == 1ULL);
+ CHECK(string_parse_size ("1 b") == 1ULL);
+ CHECK(string_parse_size ("1 B") == 1ULL);
+
+ CHECK(string_parse_size ("2") == 2ULL);
+ CHECK(string_parse_size ("2b") == 2ULL);
+ CHECK(string_parse_size ("2B") == 2ULL);
+
+ CHECK(string_parse_size ("42") == 42ULL);
+ CHECK(string_parse_size ("42b") == 42ULL);
+ CHECK(string_parse_size ("42B") == 42ULL);
+
+ /* decimals ignored for bytes */
+ CHECK(string_parse_size ("42.9") == 42ULL);
+ CHECK(string_parse_size ("42.9b") == 42ULL);
+ CHECK(string_parse_size ("42.9B") == 42ULL);
+
+ CHECK(string_parse_size ("999") == 999ULL);
+ CHECK(string_parse_size ("999b") == 999ULL);
+ CHECK(string_parse_size ("999B") == 999ULL);
+
+ CHECK(string_parse_size ("1200") == 1200ULL);
+ CHECK(string_parse_size ("1200b") == 1200ULL);
+ CHECK(string_parse_size ("1200B") == 1200ULL);
+
+ CHECK(string_parse_size ("1k") == 1000ULL);
+ CHECK(string_parse_size ("1K") == 1000ULL);
+
+ CHECK(string_parse_size ("1.34k") == 1340ULL);
+ CHECK(string_parse_size ("1.34K") == 1340ULL);
+
+ CHECK(string_parse_size ("14.08k") == 14080ULL);
+ CHECK(string_parse_size ("14.08K") == 14080ULL);
+
+ CHECK(string_parse_size ("1m") == 1000000ULL);
+ CHECK(string_parse_size ("1M") == 1000000ULL);
+
+ CHECK(string_parse_size ("1.5m") == 1500000ULL);
+ CHECK(string_parse_size ("1.5M") == 1500000ULL);
+
+ CHECK(string_parse_size ("1g") == 1000000000ULL);
+ CHECK(string_parse_size ("1G") == 1000000000ULL);
+
+ CHECK(string_parse_size ("1.2345g") == 1234500000ULL);
+ CHECK(string_parse_size ("1.2345G") == 1234500000ULL);
+
+ CHECK(string_parse_size ("1t") == 1000000000000ULL);
+ CHECK(string_parse_size ("1T") == 1000000000000ULL);
+
+ CHECK(string_parse_size ("1.23456789t") == 1234567890000ULL);
+ CHECK(string_parse_size ("1.23456789T") == 1234567890000ULL);
+}
+
/*
* Tests functions:
* string_base16_encode