<commit_before>#include <stdlib.h>
#include <check.h>
#include "../src/queue.h"

START_TEST (test_initq)
{
     struct pkt_queue q;
     initq(&q);

     fail_unless(q.npkts == 0, NULL);
     fail_unless(&q.mutex != NULL, NULL);
}
END_TEST

START_TEST (test_first_push)
{
     struct pkt_queue q;
     AVPacket pkt;
     
     initq(&q);
     pkt.pts = 1337;
     push(&q, &pkt);

     fail_unless(q.first->pkt.pts == pkt.pts);
}
END_TEST

START_TEST (test_multiple_push)
{
     struct pkt_queue q;
     AVPacket pkt;
     initq(&q);
     
     int i;
     for (i = 0; i < 100; i++) {
          pkt.pts = i;
          push(&q, &pkt);
     }

     for (i = 0; i < 100; i++) {
          fail_unless(q.first->pkt.pts == i, NULL);
          q.first = q.first->next;
     }
}
END_TEST

START_TEST (test_single_pop)
{
     struct pkt_queue q;
     AVPacket pkt;
     initq(&q);

     fail_unless(pop(&q, &pkt) == -1, NULL);
}
END_TEST

void empty_or_fail(struct pkt_queue *q) {
     fail_unless(q->npkts == 0, NULL);
     fail_unless(q->first == NULL, NULL);
     fail_unless(q->last == NULL, NULL);
}

START_TEST (test_multiple_pop)
{
     struct pkt_queue q;
     AVPacket pkt;
     initq(&q);

     int i;
     for (i = 0; i < 100; i++)
          fail_unless(pop(&q, &pkt) == -1, NULL);

     empty_or_fail(&q);
}
END_TEST

START_TEST (test_push_pop)
{
     struct pkt_queue q;
     AVPacket pkt, pkt1;
     initq(&q);
     pkt.pts = 1337;

     push(&q, &pkt);
     pop(&q, &pkt1);
     
     fail_unless(pkt1.pts == 1337, NULL);
     empty_or_fail(&q);
}
END_TEST

START_TEST (test_multiple_push_pop)
{
     struct pkt_queue q;
     AVPacket pkt, pkt1;
     initq(&q);

     int i;
     for (i = 0; i < 100; i++) {
          pkt.pts = i;
          push(&q, &pkt);
     }

     for (i = 0; i < 100; i++) {
          pop(&q, &pkt);
          fail_unless(pkt.pts == i, NULL);
     }

     empty_or_fail(&q);
          
}
END_TEST

void pusher(struct pkt_queue *q) {
     AVPacket pkt;

     int i;
     for (i = 0; i < 100; i++) {
          
     }
}

START_TEST (test_threads_push_pop) 
{
     pthread_t feeds;
}

Suite *queue_suite(void) {
     Suite *s = suite_create("queue");
     TCase *tc_core = tcase_create("core");

     tcase_add_test(tc_core, test_initq);
     tcase_add_test(tc_core, test_first_push);
     tcase_add_test(tc_core, test_multiple_push);
     tcase_add_test(tc_core, test_single_pop);
     tcase_add_test(tc_core, test_multiple_pop);
     tcase_add_test(tc_core, test_push_pop);
     tcase_add_test(tc_core, test_multiple_push_pop);
     suite_add_tcase(s, tc_core);

     return s;
}

int main() {
     int nfailed;<commit_msg>Fix build failure, all tests pass.<commit_after>#include <stdlib.h>
#include <check.h>
#include <pthread.h>
#include "../src/queue.h"

pthread_cond_t is_full = PTHREAD_COND_INITIALIZER;

START_TEST (test_initq)
{
     struct pkt_queue q;
     initq(&q);

     fail_unless(q.npkts == 0, NULL);
     fail_unless(&q.mutex != NULL, NULL);
}
END_TEST

START_TEST (test_first_push)
{
     struct pkt_queue q;
     AVPacket pkt;
     
     initq(&q);
     pkt.pts = 1337;
     push(&q, &pkt);

     fail_unless(q.first->pkt.pts == pkt.pts);
}
END_TEST

START_TEST (test_multiple_push)
{
     struct pkt_queue q;
     AVPacket pkt;
     initq(&q);
     
     int i;
     for (i = 0; i < 100; i++) {
          pkt.pts = i;
          push(&q, &pkt);
     }

     for (i = 0; i < 100; i++) {
          fail_unless(q.first->pkt.pts == i, NULL);
          q.first = q.first->next;
     }
}
END_TEST

START_TEST (test_single_pop)
{
     struct pkt_queue q;
     AVPacket pkt;
     initq(&q);

     fail_unless(pop(&q, &pkt) == -1, NULL);
}
END_TEST

void empty_or_fail(struct pkt_queue *q) {
     fail_unless(q->npkts == 0, NULL);
     fail_unless(q->first == NULL, NULL);
     fail_unless(q->last == NULL, NULL);
}

START_TEST (test_multiple_pop)
{
     struct pkt_queue q;
     AVPacket pkt;
     initq(&q);

     int i;
     for (i = 0; i < 100; i++)
          fail_unless(pop(&q, &pkt) == -1, NULL);

     empty_or_fail(&q);
}
END_TEST

START_TEST (test_push_pop)
{
     struct pkt_queue q;
     AVPacket pkt, pkt1;
     initq(&q);
     pkt.pts = 1337;

     push(&q, &pkt);
     pop(&q, &pkt1);
     
     fail_unless(pkt1.pts == 1337, NULL);
     empty_or_fail(&q);
}
END_TEST

START_TEST (test_multiple_push_pop)
{
     struct pkt_queue q;
     AVPacket pkt, pkt1;
     initq(&q);

     int i;
     for (i = 0; i < 100; i++) {
          pkt.pts = i;
          push(&q, &pkt);
     }

     for (i = 0; i < 100; i++) {
          pop(&q, &pkt);
          fail_unless(pkt.pts == i, NULL);
     }

     empty_or_fail(&q);
          
}
END_TEST

Suite *queue_suite(void) {
     Suite *s = suite_create("queue");
     TCase *tc_core = tcase_create("core");

     tcase_add_test(tc_core, test_initq);
     tcase_add_test(tc_core, test_first_push);
     tcase_add_test(tc_core, test_multiple_push);
     tcase_add_test(tc_core, test_single_pop);
     tcase_add_test(tc_core, test_multiple_pop);
     tcase_add_test(tc_core, test_push_pop);
     tcase_add_test(tc_core, test_multiple_push_pop);
     suite_add_tcase(s, tc_core);

     return s;
}

int main() {
     int nfailed;
{'fraction_non_alphanumeric': 0.14581734458940906, 'fraction_numerical': 0.016116653875671526, 'mean_word_length': 2.4138834315651603, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, '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': '2443178', 'n_tokens_mistral': 2158, 'n_tokens_neox': 2111, 'n_words': 423}