#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>

#include "datatypes.h"
#include "sumlist.h"


int main( void )
{
	intlist l = intlist_nil();
	assert( intlist_kind(l) == intlist_is_nil );

	l = intlist_cons( 100, l );

	assert( intlist_kind(l) == intlist_is_cons );
	int head; intlist tail; get_intlist_cons( l, &head, &tail );
	assert( head == 100 );
	assert( intlist_kind(tail) == intlist_is_nil );

	l = intlist_cons( 200, l );

	assert( intlist_kind(l) == intlist_is_cons );
	get_intlist_cons( l, &head, &tail );
	assert( head == 200 );
	printf( "head([200,100]) is %d\n", head );

	assert( intlist_kind(tail) == intlist_is_cons );
	get_intlist_cons( tail, &head, &tail );
	assert( head == 100 );
	printf( "head(tail[200,100]) is %d\n", head );

	l = intlist_cons( 300, l );
	l = intlist_cons( 400, l );

	int sum = sumlist( l );
	printf( "sumlist([400,300,200,100] is %d\n", sum );
	assert( sum == 1000 );

	return(0);
}
