<commit_before>/* vim:ts=8:sts=8:sw=4:noai:noexpandtab
 *
 * unit tests for transport session ID helper functions.
 *
 * Copyright (c) 2009 Miru Limited.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that 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 library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */


#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <check.h>


/* mock state */

/* mock functions for external references */


#define TSI_DEBUG
#include "tsi.c"


/* target:
 *	gchar*
 *	pgm_tsi_print (
 *		const pgm_tsi_t*	tsi
 *	)
 */

START_TEST (test_print_pass_001)
{
	const pgm_tsi_t tsi = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	fail_if (NULL == pgm_tsi_print (&tsi));
}
END_TEST

START_TEST (test_print_pass_002)
{
	fail_unless (NULL == pgm_tsi_print (NULL));
}
END_TEST

/* target:
 *	int
 *	pgm_tsi_print_r (
 *		const pgm_tsi_t*	tsi,
 *		char*			buf,
 *		gsize			bufsize
 *	)
 */

START_TEST (test_print_r_pass_001)
{
	const pgm_tsi_t tsi = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	char buf[PGM_TSISTRLEN];
	fail_unless (pgm_tsi_print_r (&tsi, buf, sizeof(buf)) > 0);
}
END_TEST

START_TEST (test_print_r_pass_002)
{
	const pgm_tsi_t tsi = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	char buf[PGM_TSISTRLEN];
	fail_unless (pgm_tsi_print_r (NULL, buf, sizeof(buf)) == -1);
	fail_unless (pgm_tsi_print_r (&tsi, NULL, sizeof(buf)) == -1);
	fail_unless (pgm_tsi_print_r (&tsi, buf, 0) == -1);
}
END_TEST

/* target:
 *	gboolean
 *	pgm_tsi_equal (
 *		gconstpointer	tsi1,
 *		gconstpointer	tsi2
 *	)
 */

START_TEST (test_equal_pass_001)
{
	const pgm_tsi_t tsi1 = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	const pgm_tsi_t tsi2 = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	fail_unless (pgm_tsi_equal (&tsi1, &tsi2));
}
END_TEST

START_TEST (test_equal_pass_002)
{
	const pgm_tsi_t tsi1 = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	const pgm_tsi_t tsi2 = { { 9, 8, 7, 6, 5, 4 }, 2000 };
	fail_if (pgm_tsi_equal (&tsi1, &tsi2));
}
END_TEST

START_TEST (test_equal_fail_001)
{
	const pgm_tsi_t tsi = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	gboolean retval = pgm_tsi_equal (NULL, &tsi);
	fail ();
}
END_TEST

START_TEST (test_equal_fail_002)
{
	const pgm_tsi_t tsi = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	gboolean retval = pgm_tsi_equal (&tsi, NULL);
	fail ();<commit_msg>Update TSI unit testing for Sun Studio.<commit_after>/* vim:ts=8:sts=8:sw=4:noai:noexpandtab
 *
 * unit tests for transport session ID helper functions.
 *
 * Copyright (c) 2009 Miru Limited.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that 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 library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */


#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <check.h>


/* mock state */

/* mock functions for external references */


#define TSI_DEBUG
#include "tsi.c"


/* target:
 *	gchar*
 *	pgm_tsi_print (
 *		const pgm_tsi_t*	tsi
 *	)
 */

START_TEST (test_print_pass_001)
{
	const pgm_tsi_t tsi = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	fail_if (NULL == pgm_tsi_print (&tsi), "print failed");
}
END_TEST

START_TEST (test_print_pass_002)
{
	fail_unless (NULL == pgm_tsi_print (NULL), "print failed");
}
END_TEST

/* target:
 *	int
 *	pgm_tsi_print_r (
 *		const pgm_tsi_t*	tsi,
 *		char*			buf,
 *		gsize			bufsize
 *	)
 */

START_TEST (test_print_r_pass_001)
{
	const pgm_tsi_t tsi = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	char buf[PGM_TSISTRLEN];
	fail_unless (pgm_tsi_print_r (&tsi, buf, sizeof(buf)) > 0, "print_r failed");
}
END_TEST

START_TEST (test_print_r_pass_002)
{
	const pgm_tsi_t tsi = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	char buf[PGM_TSISTRLEN];
	fail_unless (pgm_tsi_print_r (NULL, buf, sizeof(buf)) == -1, "print_r failed");
	fail_unless (pgm_tsi_print_r (&tsi, NULL, sizeof(buf)) == -1, "print_r failed");
	fail_unless (pgm_tsi_print_r (&tsi, buf, 0) == -1, "print_r failed");
}
END_TEST

/* target:
 *	gboolean
 *	pgm_tsi_equal (
 *		gconstpointer	tsi1,
 *		gconstpointer	tsi2
 *	)
 */

START_TEST (test_equal_pass_001)
{
	const pgm_tsi_t tsi1 = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	const pgm_tsi_t tsi2 = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	fail_unless (pgm_tsi_equal (&tsi1, &tsi2), "equal failed");
}
END_TEST

START_TEST (test_equal_pass_002)
{
	const pgm_tsi_t tsi1 = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	const pgm_tsi_t tsi2 = { { 9, 8, 7, 6, 5, 4 }, 2000 };
	fail_if (pgm_tsi_equal (&tsi1, &tsi2), "equal failed");
}
END_TEST

START_TEST (test_equal_fail_001)
{
	const pgm_tsi_t tsi = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	gboolean retval = pgm_tsi_equal (NULL, &tsi);
	fail ("reached");
}
END_TEST

START_TEST (test_equal_fail_002)
{
	const pgm_tsi_t tsi = { { 1, 2, 3, 4, 5, 6 }, 1000 };
	gboolean retval = pgm_tsi_equal (&tsi, NULL);
	fail ("reached");
{'fraction_non_alphanumeric': 0.13329945799457996, 'fraction_numerical': 0.051490514905149054, 'mean_word_length': 3.9208333333333334, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '5294119', 'n_tokens_mistral': 2682, 'n_tokens_neox': 2417, 'n_words': 716}