<commit_before>#include "signal.h"

struct ctxt {
  int sig0_func1_invoked;
  int sig0_func2_sum;
  int sig1_func_sum;
};

CALLBACK(clbk_T, struct ctxt*);

enum test_signal {
  SIG0,
  SIG1,
  SIGNALS_COUNT
};

static void
sig0_func1(struct ctxt* ctxt, void* data)
{
  CHECK(data, NULL);
  ctxt->sig0_func1_invoked = 1;
}

static void
sig0_func2(struct ctxt* ctxt, void* data)
{
  NCHECK(data, NULL);
  ctxt->sig0_func2_sum += *((int*)data);
}

static void
sig1_func(struct ctxt* ctxt, void* data)
{
  NCHECK(data, NULL);
  ctxt->sig1_func_sum += *(int*)data;
}

int
main(int argc, char** argv)
{
  (void)argc;
  (void)argv;
  struct ctxt ctxt;

  SIGNALS_LIST(slst, clbk_T, SIGNALS_COUNT);
  SIGNALS_LIST_INIT(&slst);

  clbk_T clbk0_a;
  clbk_T clbk0_b;
  clbk_T clbk0_c;
  clbk_T clbk1_a;
  clbk_T clbk1_b;
  CALLBACK_INIT(&clbk0_a);
  CALLBACK_INIT(&clbk0_b);
  CALLBACK_INIT(&clbk0_c);
  CALLBACK_INIT(&clbk1_a);
  CALLBACK_INIT(&clbk1_b);
  CALLBACK_SETUP(&clbk0_a, sig0_func1, NULL);
  CALLBACK_SETUP(&clbk0_b, sig0_func2, (int[]){12});
  CALLBACK_SETUP(&clbk0_c, sig0_func2, (int[]){-1});
  CALLBACK_SETUP(&clbk1_a, sig1_func, (int[]){2});
  CALLBACK_SETUP(&clbk1_b, sig1_func, (int[]){1});

  SIGNAL_CONNECT_CALLBACK(&slst, SIG0, &clbk0_a);
  SIGNAL_CONNECT_CALLBACK(&slst, SIG0, &clbk0_b);
  SIGNAL_CONNECT_CALLBACK(&slst, SIG0, &clbk0_c);

  ctxt.sig0_func1_invoked = 0;
  ctxt.sig0_func2_sum = 0;
  ctxt.sig1_func_sum = 0;<commit_msg>Minor adjustment of the signal test<commit_after>#include "signal.h"

struct ctxt {
  int sig0_func1_invoked;
  int sig0_func2_sum;
  int sig1_func_sum;
};

CALLBACK(clbk_T, struct ctxt*);

enum test_signal {
  SIG0,
  SIG1,
  SIGNALS_COUNT
};

static void
sig0_func1(struct ctxt* ctxt, void* data)
{
  CHECK(data, NULL);
  ctxt->sig0_func1_invoked = 1;
}

static void
sig0_func2(struct ctxt* ctxt, void* data)
{
  NCHECK(data, NULL);
  ctxt->sig0_func2_sum += *((int*)data);
}

static void
sig1_func(struct ctxt* ctxt, void* data)
{
  NCHECK(data, NULL);
  ctxt->sig1_func_sum += *(int*)data;
}

int
main(int argc, char** argv)
{
  (void)argc;
  (void)argv;
  struct ctxt ctxt;

  SIGNALS_LIST(slst, clbk_T, SIGNALS_COUNT);
  SIGNALS_LIST_INIT(&slst);

  clbk_T clbk0_a;
  clbk_T clbk0_b;
  clbk_T clbk0_c;
  clbk_T clbk1_a;
  clbk_T clbk1_b;
  CALLBACK_INIT(&clbk0_a);
  CALLBACK_INIT(&clbk0_b);
  CALLBACK_INIT(&clbk0_c);
  CALLBACK_INIT(&clbk1_a);
  CALLBACK_INIT(&clbk1_b);
  CALLBACK_SETUP(&clbk0_a, sig0_func1, NULL);
  CALLBACK_SETUP(&clbk0_b, sig0_func2, (int[]){12});
  CALLBACK_SETUP(&clbk0_c, sig0_func2, (int[]){-1});
  CALLBACK_SETUP(&clbk1_a, sig1_func, (int[]){2});
  CALLBACK_SETUP(&clbk1_b, sig1_func, (int[]){1});

  ctxt.sig0_func1_invoked = 0;
  ctxt.sig0_func2_sum = 0;
  ctxt.sig1_func_sum = 0;

  SIGNAL_INVOKE(&slst, SIG0, &ctxt);
  CHECK(ctxt.sig0_func1_invoked, 0);
  CHECK(ctxt.sig0_func2_sum, 0);
  CHECK(ctxt.sig1_func_sum, 0);

  SIGNAL_INVOKE(&slst, SIG1, &ctxt);
  CHECK(ctxt.sig0_func1_invoked, 0);
  CHECK(ctxt.sig0_func2_sum, 0);
  CHECK(ctxt.sig1_func_sum, 0);

  SIGNAL_CONNECT_CALLBACK(&slst, SIG0, &clbk0_a);
  SIGNAL_CONNECT_CALLBACK(&slst, SIG0, &clbk0_b);
  SIGNAL_CONNECT_CALLBACK(&slst, SIG0, &clbk0_c);
{'fraction_non_alphanumeric': 0.14652473387601753, 'fraction_numerical': 0.043206011271133375, 'mean_word_length': 5.520408163265306, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3780626', 'n_tokens_mistral': 1628, 'n_tokens_neox': 1529, 'n_words': 242}