<commit_before>
#include "config.h"

#include <string.h>

#include "src/util.h"

static void
test1 (void)
{
  gchar *node = NULL;
  gchar *server = NULL;
  gchar *resource = NULL;

  g_assert (!gabble_decode_jid ("", &node, &server, &resource));
  g_assert (node == NULL);
  g_assert (server == NULL);
  g_assert (resource == NULL);
  g_free (server);
}

static void
test2 (void)
{
  gchar *node = NULL;
  gchar *server = NULL;
  gchar *resource = NULL;

  g_assert (gabble_decode_jid ("bar", &node, &server, &resource));
  g_assert (node == NULL);
  g_assert (0 == strcmp (server, "bar"));
  g_assert (resource == NULL);
  g_free (server);
}

static void
test3 (void)
{
  gchar *node = NULL;
  gchar *server = NULL;
  gchar *resource = NULL;

  g_assert (gabble_decode_jid ("foo@bar", &node, &server, &resource));
  g_assert (0 == strcmp (node, "foo"));
  g_assert (0 == strcmp (server, "bar"));
  g_assert (resource == NULL);
  g_free (node);
  g_free (server);
}

static void
test4 (void)
{
  gchar *node = NULL;
  gchar *server = NULL;
  gchar *resource = NULL;

  g_assert (gabble_decode_jid ("foo@bar/baz", &node, &server, &resource));
  g_assert (0 == strcmp (node, "foo"));
  g_assert (0 == strcmp (server, "bar"));
  g_assert (0 == strcmp (resource, "baz"));
  g_free (node);
  g_free (server);
  g_free (resource);
}

static void
test5 (void)
{
  gchar *node = NULL;
  gchar *server = NULL;
  gchar *resource = NULL;

  g_assert (!gabble_decode_jid ("@bar", &node, &server, &resource));
  g_assert (node == NULL);
  g_assert (server == NULL);
  g_assert (resource == NULL);
  g_free (node);
  g_free (server);
  g_free (resource);
}

static void
test6 (void)
{
  gchar *node = NULL;
  gchar *server = NULL;
  gchar *resource = NULL;

  g_assert (!gabble_decode_jid ("foo@bar/", &node, &server, &resource));
  g_assert (node == NULL);
  g_assert (server == NULL);
  g_assert (resource == NULL);
  g_free (node);
  g_free (server);
  g_free (resource);
}

int
main (void)
{
  test1 ();
  test2 ();
  test3 ();
  test4 ();
  test5 ();
  test6 ();

  return 0;
}
<commit_msg>test-jid-decode: rename server -> domain for consistency<commit_after>
#include "config.h"

#include <string.h>

#include "src/util.h"

static void
test1 (void)
{
  gchar *node = NULL;
  gchar *domain = NULL;
  gchar *resource = NULL;

  g_assert (!gabble_decode_jid ("", &node, &domain, &resource));
  g_assert (node == NULL);
  g_assert (domain == NULL);
  g_assert (resource == NULL);
  g_free (domain);
}

static void
test2 (void)
{
  gchar *node = NULL;
  gchar *domain = NULL;
  gchar *resource = NULL;

  g_assert (gabble_decode_jid ("bar", &node, &domain, &resource));
  g_assert (node == NULL);
  g_assert (0 == strcmp (domain, "bar"));
  g_assert (resource == NULL);
  g_free (domain);
}

static void
test3 (void)
{
  gchar *node = NULL;
  gchar *domain = NULL;
  gchar *resource = NULL;

  g_assert (gabble_decode_jid ("foo@bar", &node, &domain, &resource));
  g_assert (0 == strcmp (node, "foo"));
  g_assert (0 == strcmp (domain, "bar"));
  g_assert (resource == NULL);
  g_free (node);
  g_free (domain);
}

static void
test4 (void)
{
  gchar *node = NULL;
  gchar *domain = NULL;
  gchar *resource = NULL;

  g_assert (gabble_decode_jid ("foo@bar/baz", &node, &domain, &resource));
  g_assert (0 == strcmp (node, "foo"));
  g_assert (0 == strcmp (domain, "bar"));
  g_assert (0 == strcmp (resource, "baz"));
  g_free (node);
  g_free (domain);
  g_free (resource);
}

static void
test5 (void)
{
  gchar *node = NULL;
  gchar *domain = NULL;
  gchar *resource = NULL;

  g_assert (!gabble_decode_jid ("@bar", &node, &domain, &resource));
  g_assert (node == NULL);
  g_assert (domain == NULL);
  g_assert (resource == NULL);
  g_free (node);
  g_free (domain);
  g_free (resource);
}

static void
test6 (void)
{
  gchar *node = NULL;
  gchar *domain = NULL;
  gchar *resource = NULL;

  g_assert (!gabble_decode_jid ("foo@bar/", &node, &domain, &resource));
  g_assert (node == NULL);
  g_assert (domain == NULL);
  g_assert (resource == NULL);
  g_free (node);
  g_free (domain);
  g_free (resource);
}

int
main (void)
{
  test1 ();
  test2 ();
  test3 ();
  test4 ();
  test5 ();
  test6 ();

  return 0;
}

{'fraction_non_alphanumeric': 0.17384066587395958, 'fraction_numerical': 0.009036860879904875, 'mean_word_length': 3.879350348027842, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '4788652', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1642, 'n_words': 451}