Initial Commit

This commit is contained in:
Marc
2025-09-13 14:40:16 +02:00
commit ded01301c2
383 changed files with 71046 additions and 0 deletions

101
OU1/int_stack_test_marc.c Normal file
View File

@@ -0,0 +1,101 @@
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h> // for EXIT_FAILURE
/*#include <int_list.h>*/
#include <int_stack.h>
/*#include <stack.h>*/
/*
* Stub test program for the list implementation in list.c.
*
* Author: Niclas Borlin (niclas.borlin@cs.umu.se).
*
* Version information:
* 2018-01-28: v1.0. First public version.
* 2019-01-23: v1.1. Added file comment. Removed memory cleanup on failure.
* 2023-01-21: v2.0. Complete re-write. Semi-serious attempt at a complete test program for
* int_list.
* 2023-01-21: v2.01. Updated print identification command.
* 2023-03-23: v2.1. Renamed list_pos_are_equal to list_pos_is_equal.
* 2023-03-23: v2.2. Removed empty if statements in test code.
*/
#define VERSION "v2.2"
#define VERSION_DATE "2023-03-23"
/*
* Function to compare the values stored in the list.
*/
bool value_equal(int v1, int v2)
{
return v1 == v2;
}
void isempty_return_true(void)
{
stack s = stack_empty();
if (stack_is_empty(s) == false){
fprintf(stderr,"\nStack is empty but \"stack_is_empty\" reports non empty\n");
/*return 1;*/
}
stack_print(s);
s = stack_push(s,10);
stack_print(s);
if (stack_is_empty(s) == true){
fprintf(stderr,"\nStack is non empty but \"stack_is_empty\" reports empty.\n");
/*return 1;*/
}
fprintf(stderr,"\n \"stack_is_empty\" function works!\n");
stack_kill(s);
{/*
s = stack_push(s,2);
int x;
x = stack_top(s);
fprintf(stderr,"value x: %x\n",x);
int truevalue;
truevalue = stack_is_empty(s);
value_equal(truevalue,true);
stack_print(s);
*/
/*if s == { }*/
}
}
void push_stack_on_top(void)
{
stack s = stack_empty();
s = stack_push(s,1);
s = stack_push(s,2);
if (stack_top(s) == 1){
fprintf(stderr,"\n\"stack_push\" puts values in wrong order.\n");
}
}
int main(void)
{
printf("%s, %s %s: Test program for the typed int_stack datatype.\n",
__FILE__, VERSION, VERSION_DATE);
printf("Code base version %s.\n\n", CODE_BASE_VERSION);
isempty_return_true();
fprintf(stderr,"\nSUCCESS: Implementation passed all tests. Normal exit.\n");
return 0;
}