<commit_before>#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include "dt-core.h"

#define CHECK(pred, args...)			\
	if (pred) {				\
		fprintf(stderr, args);		\
		res = 1;			\
	}

static int
test_d_only_no_fmt(void)
{
	static const char str[] = "2012-03-28";
	struct dt_dt_s d;
	int res = 0;

	/* 2012-03-28 (using no format) */
	fprintf(stderr, "testing %s ...\n", str);
	d = dt_strpdt(str, NULL, NULL);

	CHECK(!dt_sandwich_only_d_p(d), "  TYPE is not a d-only\n");
	CHECK(d.d.typ != DT_YMD,
	      "  TYPE DIFFERS %u ... should be %u\n",
	      (unsigned int)d.d.typ,
	      (unsigned int)DT_YMD);
	CHECK(d.t.u,
	      "  TIME COMPONENT NOT NAUGHT %" PRIu64 "\n",
	      (uint64_t)d.t.u);
	CHECK(d.dur, "  DURATION BIT SET\n");
	CHECK(d.neg, "  NEGATED BIT SET\n");
	CHECK(d.t.dur, "  TIME DURATION BIT SET\n");
	CHECK(d.t.neg, "  TIME NEGATED BIT SET\n");

	CHECK(d.d.ymd.y != 2012,
	      "  YEAR %u ... should be 2012\n",
	      (unsigned int)d.d.ymd.y);
	CHECK(d.d.ymd.m != 3,
	      "  MONTH %u ... should be 3\n",
	      (unsigned int)d.d.ymd.m);
	CHECK(d.d.ymd.d != 28,
	      "  DAY %u ... should be 28\n",
	      (unsigned int)d.d.ymd.d);
	/* make sure the padding leaves no garbage */
	CHECK(d.d.ymd.u & ~0x1fffff,
	      "  PADDING NOT NAUGHT %u\n",
	      (unsigned int)(d.d.ymd.u & ~0x1fffff));
	return res;
}

static int
test_t_only_no_fmt(void)
{
	static const char str[] = "12:34:56";
	struct dt_dt_s d;
	int res = 0;

	/* 12:34:56 (using no format) */
	fprintf(stderr, "testing %s ...\n", str);
	d = dt_strpdt(str, NULL, NULL);

	CHECK(d.typ != DT_SANDWICH_UNK,
	      "  TYPE DIFFERS %u ... should be %u\n",
	      (unsigned int)d.typ,
	      (unsigned int)DT_SANDWICH_UNK);<commit_msg>test, fix, check for t-only-ness<commit_after>#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include "dt-core.h"

#define CHECK(pred, args...)			\
	if (pred) {				\
		fprintf(stderr, args);		\
		res = 1;			\
	}

static int
test_d_only_no_fmt(void)
{
	static const char str[] = "2012-03-28";
	struct dt_dt_s d;
	int res = 0;

	/* 2012-03-28 (using no format) */
	fprintf(stderr, "testing %s ...\n", str);
	d = dt_strpdt(str, NULL, NULL);

	CHECK(!dt_sandwich_only_d_p(d), "  TYPE is not a d-only\n");
	CHECK(d.d.typ != DT_YMD,
	      "  TYPE DIFFERS %u ... should be %u\n",
	      (unsigned int)d.d.typ,
	      (unsigned int)DT_YMD);
	CHECK(d.t.u,
	      "  TIME COMPONENT NOT NAUGHT %" PRIu64 "\n",
	      (uint64_t)d.t.u);
	CHECK(d.dur, "  DURATION BIT SET\n");
	CHECK(d.neg, "  NEGATED BIT SET\n");
	CHECK(d.t.dur, "  TIME DURATION BIT SET\n");
	CHECK(d.t.neg, "  TIME NEGATED BIT SET\n");

	CHECK(d.d.ymd.y != 2012,
	      "  YEAR %u ... should be 2012\n",
	      (unsigned int)d.d.ymd.y);
	CHECK(d.d.ymd.m != 3,
	      "  MONTH %u ... should be 3\n",
	      (unsigned int)d.d.ymd.m);
	CHECK(d.d.ymd.d != 28,
	      "  DAY %u ... should be 28\n",
	      (unsigned int)d.d.ymd.d);
	/* make sure the padding leaves no garbage */
	CHECK(d.d.ymd.u & ~0x1fffff,
	      "  PADDING NOT NAUGHT %u\n",
	      (unsigned int)(d.d.ymd.u & ~0x1fffff));
	return res;
}

static int
test_t_only_no_fmt(void)
{
	static const char str[] = "12:34:56";
	struct dt_dt_s d;
	int res = 0;

	/* 12:34:56 (using no format) */
	fprintf(stderr, "testing %s ...\n", str);
	d = dt_strpdt(str, NULL, NULL);

	CHECK(!dt_sandwich_only_t_p(d), "  TYPE is not a t-only\n");
	CHECK(d.typ != DT_SANDWICH_UNK,
	      "  TYPE DIFFERS %u ... should be %u\n",
	      (unsigned int)d.typ,
	      (unsigned int)DT_SANDWICH_UNK);
{'fraction_non_alphanumeric': 0.18797845194216048, 'fraction_numerical': 0.03005387014459881, 'mean_word_length': 2.5492957746478875, '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': '7347667', 'n_tokens_mistral': 1705, 'n_tokens_neox': 1575, 'n_words': 353}