* Anthony Minessale II <anthm@freeswitch.org>
* Juan Jose Comellas <juanjo@comellas.org>
* Seven Du <dujinfang@gmail.com>
- *
+ * Windy Wang <xiaofengcanyuexp@163.com>
*
* switch_utils.c -- Compatibility and Helper Code
*
while (l >= 8) {
op[ol++] = (char) ((b >> (l -= 8)) % 256);
- if (ol >= olen - 2) {
+ if (ol >= olen - 1) {
goto end;
}
}
*
* Contributor(s):
* Seven Du <seven@signalwire.com>
- *
+ * Windy Wang <xiaofengcanyuexp@163.com>
*
* switch_utils.c -- tests switch_utils
*
}
FST_TEST_END()
+FST_TEST_BEGIN(b64)
+{
+ char *str = "ABC";
+ unsigned char b64_str[6];
+ char decoded_str[4];
+ switch_status_t status = switch_b64_encode((unsigned char *)str, strlen(str), b64_str, sizeof(b64_str));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "b64_str: %s\n", b64_str);
+ fst_check(status == SWITCH_STATUS_SUCCESS);
+ fst_check_string_equals((const char *)b64_str, "QUJD");
+
+ switch_size_t size = switch_b64_decode((const char *)b64_str, decoded_str, sizeof(decoded_str));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "decoded_str: %s\n", decoded_str);
+ fst_check_string_equals(decoded_str, str);
+ fst_check(size == 4);
+}
+FST_TEST_END()
+
+
FST_SUITE_END()
FST_MINCORE_END()