file page test 2

This commit is contained in:
JDobeshow 2022-08-29 17:38:33 +02:00
parent 4e3fb0cb65
commit 4cf7349d51
4 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1 @@
run

View File

@ -0,0 +1,5 @@
#!/bin/sh
if [ ! -d run ]; then
mkdir run
fi
gcc -g filePageTest2.c "../../../System Abstraction/linux/cdb_file.c" "../../../System Abstraction/linux/cdb_memroy.c" "../../../File-Page Abstraction/cdb_file-page.c" -o run/filePageTest2

View File

@ -0,0 +1,36 @@
#include "../../../File-Page Abstraction/cdb_file-page.h"
#include <stdio.h>
int main() {
fp_File file = fp_fileTemp("created", 512);
if(file == NULL) {
printf("file is null\n");
return 1;
}
char * memory = fp_fileToMemroy(file);
memory[0] = 'a';
memory[511] = 'b';
printf("Append pages\n");
memory = fp_fileAppendPages(file, 1);
if(memory == NULL) {
printf("memory is null\n");
return 1;
}
memory[1023] = 'z';
printf("Close\n");
fp_fileClose(file);
printf("Open\n");
file = fp_fileOpen("created");
if(file == NULL) {
printf("second file is null\n");
return 0;
}else {
printf("second file was NOT null\n");
return 1;
}
}

View File

@ -0,0 +1,18 @@
#!/bin/sh
./compile.sh
cd run
# Test 1
echo "-- Test 1"
echo "Expected output: second file is null"
./filePageTest2
# Test 2
echo "-- Test 2"
echo "Expected output: file is null"
touch created
./filePageTest2
rm created
cd ..