summaryrefslogtreecommitdiff
path: root/test/utf8.c
blob: 88e6a8cc7537d8e4e0c202d7b4c3603b14c1a6c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "utf8.h"
#include "assert.h"
#include "test.h"
#include "wchar.h"

#include <string.h>

void test_nchars_nbytes() {
  ASSERT(utf8_nchars((uint8_t *)"👴", strlen("👴")) == 1,
         "Expected old man emoji to be 1 char");
  ASSERT(utf8_nbytes((uint8_t *)"👴", strlen("👴"), 1) == 4,
         "Expected old man emoji to be 4 bytes");
}

void run_utf8_tests() { run_test(test_nchars_nbytes); }