<commit_before>/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */

/*
 * Copyright (c) 2011, Intel Corporation.
 *
 * Author: <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#include <ytstenut-glib/ytsg-status.h>
#include <string.h>

int
main (int argc, char **argv)
{
  YtsgStatus  *status1, *status2;
  const char  *attrs[] = {"a1", "v1", "a2", "v2", NULL};
  const char  *a1, *a2, *a3;
  RestXmlNode *top1, *top2, *child11, *child12, *child21, *child22;

  g_thread_init (NULL);
  g_type_init ();

  status1 = ytsg_status_new (attrs);

  ytsg_metadata_add_attribute ((YtsgMetadata*)status1, "a3", "v3");
  a1 = ytsg_metadata_get_attribute ((YtsgMetadata*)status1, "a1");
  a2 = ytsg_metadata_get_attribute ((YtsgMetadata*)status1, "a2");
  a3 = ytsg_metadata_get_attribute ((YtsgMetadata*)status1, "a3");

  g_assert_cmpstr (a1, ==, "v1");
  g_assert_cmpstr (a2, ==, "v2");
  g_assert_cmpstr (a3, ==, "v3");

  status2 = ytsg_status_new (attrs);

  g_assert (!ytsg_metadata_equal ((YtsgMetadata*)status1,
                                  (YtsgMetadata*)status2));

  ytsg_metadata_add_attribute ((YtsgMetadata*)status2, "a3", "v3");

  g_assert (ytsg_metadata_equal ((YtsgMetadata*)status1,
                                 (YtsgMetadata*)status2));

  top1 = ytsg_metadata_get_top_node ((YtsgMetadata*)status1);
  top2 = ytsg_metadata_get_top_node ((YtsgMetadata*)status2);

  child11 = rest_xml_node_add_child (top1, "t");
  child12 = rest_xml_node_add_child (top1, "t");

  child21 = rest_xml_node_add_child (top2, "t");
  child22 = rest_xml_node_add_child (top2, "t");

  g_assert (ytsg_metadata_equal ((YtsgMetadata*)status1,
                                 (YtsgMetadata*)status2));

  rest_xml_node_add_attr (child11, "a4", "v4");
  rest_xml_node_add_attr (child21, "a4", "v4");

  g_assert (ytsg_metadata_equal ((YtsgMetadata*)status1,
                                 (YtsgMetadata*)status2));

  rest_xml_node_add_attr (child21, "a5", "v5");

  g_assert (!ytsg_metadata_equal ((YtsgMetadata*)status1,
                                  (YtsgMetadata*)status2));

  return 0;
}<commit_msg>tests: Improved YtsgStatus test<commit_after>/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */

/*
 * Copyright (c) 2011, Intel Corporation.
 *
 * Author: <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#include <ytstenut-glib/ytsg-status.h>
#include <ytstenut-glib/ytsg-message.h>
#include <string.h>

int
main (int argc, char **argv)
{
  YtsgStatus  *status1, *status2;
  YtsgMessage *message;
  const char  *attrs[] = {"a1", "v1", "a2", "v2", NULL};
  const char  *a1, *a2, *a3;
  RestXmlNode *top1, *top2, *child11, *child12, *child21, *child22;

  g_thread_init (NULL);
  g_type_init ();

  status1 = ytsg_status_new (attrs);

  ytsg_metadata_add_attribute ((YtsgMetadata*)status1, "a3", "v3");
  a1 = ytsg_metadata_get_attribute ((YtsgMetadata*)status1, "a1");
  a2 = ytsg_metadata_get_attribute ((YtsgMetadata*)status1, "a2");
  a3 = ytsg_metadata_get_attribute ((YtsgMetadata*)status1, "a3");

  g_assert_cmpstr (a1, ==, "v1");
  g_assert_cmpstr (a2, ==, "v2");
  g_assert_cmpstr (a3, ==, "v3");

  status2 = ytsg_status_new (attrs);

  g_assert (!ytsg_metadata_equal ((YtsgMetadata*)status1,
                                  (YtsgMetadata*)status2));

  ytsg_metadata_add_attribute ((YtsgMetadata*)status2, "a3", "v3");

  g_assert (ytsg_metadata_equal ((YtsgMetadata*)status1,
                                 (YtsgMetadata*)status2));

  top1 = ytsg_metadata_get_top_node ((YtsgMetadata*)status1);
  top2 = ytsg_metadata_get_top_node ((YtsgMetadata*)status2);

  child11 = rest_xml_node_add_child (top1, "t");
  child12 = rest_xml_node_add_child (top1, "t");

  child21 = rest_xml_node_add_child (top2, "t");
  child22 = rest_xml_node_add_child (top2, "t");

  g_assert (ytsg_metadata_equal ((YtsgMetadata*)status1,
                                 (YtsgMetadata*)status2));

  rest_xml_node_add_attr (child11, "a4", "v4");
  rest_xml_node_add_attr (child21, "a4", "v4");

  g_assert (ytsg_metadata_equal ((YtsgMetadata*)status1,
                                 (YtsgMetadata*)status2));

  rest_xml_node_add_attr (child21, "a5", "v5");

  g_assert (!ytsg_metadata_equal ((YtsgMetadata*)status1,
                                  (YtsgMetadata*)status2));

  message = ytsg_message_new (NULL);

  g_assert (!ytsg_metadata_equal ((YtsgMetadata*)status1,
                                  (YtsgMetadata*)message));

  return 0;
}
{'fraction_non_alphanumeric': 0.12976046872307428, 'fraction_numerical': 0.03394795795278304, 'mean_word_length': 3.7034035656401945, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6460810', 'n_tokens_mistral': 2117, 'n_tokens_neox': 2022, 'n_words': 510}