reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
vector_test.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "vector.h"
#include "rand_utils.h"
#include "util.h"

Macros

#define CAPACITY   100
 
#define MAX_PUSHALL   8
 
#define N   5000
 
#define RANDOM_SEED   1614
 

Functions

void test_push (vector_t *v)
 Test the append functionality of v.
 
void test_pop (vector_t *v)
 Test the pop functionality of v.
 
int test_pushall (vector_t *v)
 Test the "push all" functionality of v.
 
void test_random_access (vector_t *v)
 Check that the result of a random access to v yields the correct result.
 
void test_vote (vector_t *v)
 Check that voting does not cause an error.
 
int run_test (vector_t *v, int *distribution)
 Run a randomly selected test on v.
 
int main ()
 

Macro Definition Documentation

◆ CAPACITY

#define CAPACITY   100

◆ MAX_PUSHALL

#define MAX_PUSHALL   8

◆ N

#define N   5000

◆ RANDOM_SEED

#define RANDOM_SEED   1614

Function Documentation

◆ main()

int main ( )

◆ run_test()

int run_test ( vector_t * v,
int * distribution )

Run a randomly selected test on v.

Parameters
vA vector.
distributionThe desired probability distribution with which each of four actions are performed, expressed as percents.
Returns
An integer that is lower-bounded by 1 and upper-bounded by the number of items added to v.

◆ test_pop()

void test_pop ( vector_t * v)

Test the pop functionality of v.

Parameters
vA vector.

◆ test_push()

void test_push ( vector_t * v)

Test the append functionality of v.

Parameters
vA vector.
xAny pointer.

◆ test_pushall()

int test_pushall ( vector_t * v)

Test the "push all" functionality of v.

Parameters
vA vector
Returns
The number of items pushed to v.

◆ test_random_access()

void test_random_access ( vector_t * v)

Check that the result of a random access to v yields the correct result.

Parameters
vA vector.

◆ test_vote()

void test_vote ( vector_t * v)

Check that voting does not cause an error.

Parameters
vA vector.