<commit_before>#include <stdio.h>

#include <glib.h>

#include <telepathy-glib/util.h>

void test_strv_contains (void);

void
test_strv_contains (void)
{
  const gchar * const strv[] = {
      "Pah",
      "Pah",
      "Pah-pah-pah",
      "Patrick!",
      NULL
  };

  g_assert (tp_strv_contains (strv, "Patrick!"));
  g_assert (!tp_strv_contains (strv, "Snakes!"));
}

static void
test_value_array_build (void)
{
  GValueArray *arr;
  const gchar *host = "badger.snakes";
  guint port = 128;
  gchar *host_out = NULL;
  guint port_out = 1234;

  arr = tp_value_array_build (2,
    G_TYPE_STRING, host,
    G_TYPE_UINT, port,
    G_TYPE_INVALID);

  g_assert_cmpstr (g_value_get_string (g_value_array_get_nth (arr, 0)), ==,
      host);
  g_assert_cmpuint (g_value_get_uint (g_value_array_get_nth (arr, 1)), ==,
      port);

  tp_value_array_unpack (arr, 2,
      &host_out,
      &port_out);

  g_assert_cmpstr (host_out, ==, host);
  g_assert_cmpuint (port_out, ==, port);

  g_value_array_free (arr);
}

int main (int argc, char **argv)
{
  GPtrArray *ptrarray;
  gchar *string;

  g_type_init ();

  g_assert (!tp_strdiff (NULL, NULL));
  g_assert (tp_strdiff ("badger", NULL));
  g_assert (tp_strdiff (NULL, "badger"));
  g_assert (!tp_strdiff ("badger", "badger"));
  g_assert (tp_strdiff ("badger", "mushroom"));

  ptrarray = g_ptr_array_new ();
  g_ptr_array_add (ptrarray, GINT_TO_POINTER (23));
  g_ptr_array_add (ptrarray, GINT_TO_POINTER (42));
  g_assert (tp_g_ptr_array_contains (ptrarray, GINT_TO_POINTER (23)));
  g_assert (tp_g_ptr_array_contains (ptrarray, GINT_TO_POINTER (42)));
  g_assert (!tp_g_ptr_array_contains (ptrarray, GINT_TO_POINTER (666)));
  g_ptr_array_free (ptrarray, TRUE);

  string = tp_escape_as_identifier ("");
  g_assert (!tp_strdiff (string, "_"));
  g_free (string);

  string = tp_escape_as_identifier ("badger");
  g_assert (!tp_strdiff (string, "badger"));
  g_free (string);

  string = tp_escape_as_identifier ("0123abc_xyz\x01\xff");
  g_assert (!tp_strdiff (string, "_30123abc_5fxyz_01_ff"));
  g_free (string);

  test_strv_contains ();

  test_value_array_build ();

  return 0;
}<commit_msg>Add utf8 char to the tests of tp_escape_as_identifier()<commit_after>#include <stdio.h>

#include <glib.h>

#include <telepathy-glib/util.h>

void test_strv_contains (void);

void
test_strv_contains (void)
{
  const gchar * const strv[] = {
      "Pah",
      "Pah",
      "Pah-pah-pah",
      "Patrick!",
      NULL
  };

  g_assert (tp_strv_contains (strv, "Patrick!"));
  g_assert (!tp_strv_contains (strv, "Snakes!"));
}

static void
test_value_array_build (void)
{
  GValueArray *arr;
  const gchar *host = "badger.snakes";
  guint port = 128;
  gchar *host_out = NULL;
  guint port_out = 1234;

  arr = tp_value_array_build (2,
    G_TYPE_STRING, host,
    G_TYPE_UINT, port,
    G_TYPE_INVALID);

  g_assert_cmpstr (g_value_get_string (g_value_array_get_nth (arr, 0)), ==,
      host);
  g_assert_cmpuint (g_value_get_uint (g_value_array_get_nth (arr, 1)), ==,
      port);

  tp_value_array_unpack (arr, 2,
      &host_out,
      &port_out);

  g_assert_cmpstr (host_out, ==, host);
  g_assert_cmpuint (port_out, ==, port);

  g_value_array_free (arr);
}

int main (int argc, char **argv)
{
  GPtrArray *ptrarray;
  gchar *string;

  g_type_init ();

  g_assert (!tp_strdiff (NULL, NULL));
  g_assert (tp_strdiff ("badger", NULL));
  g_assert (tp_strdiff (NULL, "badger"));
  g_assert (!tp_strdiff ("badger", "badger"));
  g_assert (tp_strdiff ("badger", "mushroom"));

  ptrarray = g_ptr_array_new ();
  g_ptr_array_add (ptrarray, GINT_TO_POINTER (23));
  g_ptr_array_add (ptrarray, GINT_TO_POINTER (42));
  g_assert (tp_g_ptr_array_contains (ptrarray, GINT_TO_POINTER (23)));
  g_assert (tp_g_ptr_array_contains (ptrarray, GINT_TO_POINTER (42)));
  g_assert (!tp_g_ptr_array_contains (ptrarray, GINT_TO_POINTER (666)));
  g_ptr_array_free (ptrarray, TRUE);

  string = tp_escape_as_identifier ("");
  g_assert (!tp_strdiff (string, "_"));
  g_free (string);

  string = tp_escape_as_identifier ("badger");
  g_assert (!tp_strdiff (string, "badger"));
  g_free (string);

  string = tp_escape_as_identifier ("0123abc_xyz\x01\xff");
  g_assert (!tp_strdiff (string, "_30123abc_5fxyz_01_ff"));
  g_free (string);

  string = tp_escape_as_identifier ("©");
  g_assert (!tp_strdiff (string,  "_c2_a9"));
  g_free (string);

  test_strv_contains ();

  test_value_array_build ();

  return 0;
}
{'fraction_non_alphanumeric': 0.14327485380116958, 'fraction_numerical': 0.01731893837156995, 'mean_word_length': 4.657760814249364, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5672550', 'n_tokens_mistral': 1878, 'n_tokens_neox': 1797, 'n_words': 354}