16#include "threads/test.h"
32 printf (
"testing various size arrays:");
33 for (cnt = 0; cnt <
MAX_CNT; cnt = cnt * 4 / 3 + 1)
38 for (repeat = 0; repeat < 10; repeat++)
44 for (i = 0; i < cnt; i++)
65 for (i = 0; i < cnt; i++)
83 return *a < *b ? -1 : *a > *b;
92 for (i = 0; (
size_t) i < cnt; i++)
105 for (i = 0; (
size_t) i < cnt; i++)
110 not_in_array[0] = cnt;
111 for (i = 0; (
size_t) i <
sizeof not_in_array /
sizeof *not_in_array; i++)
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
int printf(const char *format,...)
Writes formatted output to the console.
void * bsearch(const void *key, const void *array, size_t cnt, size_t size, int(*compare)(const void *, const void *))
Searches ARRAY, which contains CNT elements of SIZE bytes each, for the given KEY.
void qsort(void *array, size_t cnt, size_t size, int(*compare)(const void *, const void *))
Sorts ARRAY, which contains CNT elements of SIZE bytes each, using COMPARE.
unsigned long random_ulong(void)
Returns a pseudo-random unsigned long.
__SIZE_TYPE__ size_t
lib/stddef.h
static void verify_bsearch(const int[], size_t)
void test(void)
Test sorting and searching implementations.
static void shuffle(int[], size_t)
#define MAX_CNT
Test program for sorting and searching in lib/stdlib.c.
static void verify_order(const int[], size_t)
static int compare_ints(const void *, const void *)
Returns 1 if *A is greater than *B, 0 if *A equals *B, -1 if *A is less than *B.