Add test_strquote
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
This commit is contained in:
parent
3100533e56
commit
5eeaed09ae
1 changed files with 12 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue