file page test 2
This commit is contained in:
parent
4e3fb0cb65
commit
4cf7349d51
1
tests/File-Page Abstraction/2/.gitignore
vendored
Normal file
1
tests/File-Page Abstraction/2/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
run
|
5
tests/File-Page Abstraction/2/compile.sh
Executable file
5
tests/File-Page Abstraction/2/compile.sh
Executable 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
|
36
tests/File-Page Abstraction/2/filePageTest2.c
Normal file
36
tests/File-Page Abstraction/2/filePageTest2.c
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
18
tests/File-Page Abstraction/2/run.sh
Executable file
18
tests/File-Page Abstraction/2/run.sh
Executable 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 ..
|
Loading…
Reference in New Issue
Block a user