Skip to content

Display and control your Android device

Add test_strquote

Yu-Chen Lin5eeaed09aed6
diff --git a/app/tests/test_strutil.c b/app/tests/test_strutil.c
index 64e62ed1..1489b1bd 100644
--- a/app/tests/test_strutil.c
+++ b/app/tests/test_strutil.c
@@ -1,5 +1,6 @@
#include <assert.h>
#include <string.h>
+#include <SDL2/SDL.h>
#include "util/str_util.h"
@@ -126,6 +127,16 @@ static void test_xstrjoin_truncated_after_sep(void) {
assert(!strcmp("abc de ", s));
}
+static void test_strquote(void) {
+ const char *s = "abcde";
+ char *out = strquote(s);
+
+ // add '"' at the beginning and the end
+ assert(!strcmp("\"abcde\"", out));
+
+ SDL_free(out);
+}
+
static void test_utf8_truncate(void) {
const char *s = "aÉbÔc";
assert(strlen(s) == 7); // É and Ô are 2 bytes-wide
@@ -166,6 +177,7 @@ int main(void) {
test_xstrjoin_truncated_in_token();
test_xstrjoin_truncated_before_sep();
test_xstrjoin_truncated_after_sep();
+ test_strquote();
test_utf8_truncate();
return 0;
}