some unit tests for da system abstraction layer
sus
This commit is contained in:
parent
b6564966cf
commit
223210bf4c
1
tests/System Abstraction/1/compile.bat
Normal file
1
tests/System Abstraction/1/compile.bat
Normal file
@ -0,0 +1 @@
|
||||
gcc.exe systemAbstractionTest1.c "../../../System Abstraction/win32/cdb_file.c" "../../../System Abstraction/win32/cdb_memroy.c" -o systemAbstractionTest1.exe
|
33
tests/System Abstraction/1/systemAbstractionTest1.c
Normal file
33
tests/System Abstraction/1/systemAbstractionTest1.c
Normal file
@ -0,0 +1,33 @@
|
||||
#include "..\System Abstraction/cdb_Sustem.h"
|
||||
#include "stdio.h"
|
||||
|
||||
void main(){
|
||||
sus_File file = sus_fileOpenInMem("testfile.txt", SUS_FILE_NOTHING);
|
||||
if(file == NULL){
|
||||
printf("file is null");
|
||||
return;
|
||||
}
|
||||
|
||||
char * memroy = sus_fileFileToMemroy(file);
|
||||
if(memroy == 0){
|
||||
printf("memroy was null\n");
|
||||
return;
|
||||
}else{
|
||||
printf("%c%c%c%c", memroy[0], memroy[1], memroy[2], memroy[3]);
|
||||
}
|
||||
|
||||
sus_fileResize(file, 2);
|
||||
memroy = sus_fileFileToMemroy(file);
|
||||
memroy[0] = 'a';
|
||||
memroy[1] = 'b';
|
||||
memroy[2] = 'c';
|
||||
memroy[3] = 'd';
|
||||
memroy[4] = 'e';
|
||||
sus_fileFlush(file);
|
||||
sus_fileClose(file);
|
||||
file = sus_fileOpenInMem("testfile.txt", SUS_FILE_NOTHING);
|
||||
memroy = sus_fileFileToMemroy(file);
|
||||
memroy[0] = 'O';
|
||||
sus_fileFlush(file);
|
||||
sus_fileClose(file);
|
||||
}
|
BIN
tests/System Abstraction/1/systemAbstractionTest1.exe
Normal file
BIN
tests/System Abstraction/1/systemAbstractionTest1.exe
Normal file
Binary file not shown.
1
tests/System Abstraction/1/testfile.txt
Normal file
1
tests/System Abstraction/1/testfile.txt
Normal file
@ -0,0 +1 @@
|
||||
Obc
|
1
tests/System Abstraction/2/compile.bat
Normal file
1
tests/System Abstraction/2/compile.bat
Normal file
@ -0,0 +1 @@
|
||||
gcc.exe openNewFiletest.c "../../../System Abstraction/win32/cdb_file.c" "../../../System Abstraction/win32/cdb_memroy.c" -o systemAbstractionTest1.exe
|
33
tests/System Abstraction/2/openNewFiletest.c
Normal file
33
tests/System Abstraction/2/openNewFiletest.c
Normal file
@ -0,0 +1,33 @@
|
||||
#include "..\..\..\System Abstraction/cdb_Sustem.h"
|
||||
#include "stdio.h"
|
||||
|
||||
void main(){
|
||||
sus_File file = sus_fileOpenInMem("testfile.txt", SUS_FILE_NEW);
|
||||
if(file == NULL){
|
||||
printf("file is null");
|
||||
return;
|
||||
}
|
||||
|
||||
char * memroy = sus_fileFileToMemroy(file);
|
||||
if(memroy == 0){
|
||||
printf("memroy was null\n");
|
||||
return;
|
||||
}else{
|
||||
printf("%c%c%c%c", memroy[0], memroy[1], memroy[2], memroy[3]);
|
||||
}
|
||||
|
||||
sus_fileResize(file, 2);
|
||||
memroy = sus_fileFileToMemroy(file);
|
||||
memroy[0] = 'a';
|
||||
memroy[1] = 'b';
|
||||
memroy[2] = 'c';
|
||||
memroy[3] = 'd';
|
||||
memroy[4] = 'e';
|
||||
sus_fileFlush(file);
|
||||
sus_fileClose(file);
|
||||
file = sus_fileOpenInMem("testfile.txt", SUS_FILE_NOTHING);
|
||||
memroy = sus_fileFileToMemroy(file);
|
||||
memroy[0] = 'O';
|
||||
sus_fileFlush(file);
|
||||
sus_fileClose(file);
|
||||
}
|
BIN
tests/System Abstraction/2/systemAbstractionTest1.exe
Normal file
BIN
tests/System Abstraction/2/systemAbstractionTest1.exe
Normal file
Binary file not shown.
1
tests/System Abstraction/2/testfile.txt
Normal file
1
tests/System Abstraction/2/testfile.txt
Normal file
@ -0,0 +1 @@
|
||||
Obc
|
0
tests/System Abstraction/2/testfile2.txt
Normal file
0
tests/System Abstraction/2/testfile2.txt
Normal file
1
tests/System Abstraction/3/compile.bat
Normal file
1
tests/System Abstraction/3/compile.bat
Normal file
@ -0,0 +1 @@
|
||||
gcc.exe openTempFiletest.c "../../../System Abstraction/win32/cdb_file.c" "../../../System Abstraction/win32/cdb_memroy.c" -o openTempFiletest.exe
|
34
tests/System Abstraction/3/openTempFiletest.c
Normal file
34
tests/System Abstraction/3/openTempFiletest.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include "..\..\..\System Abstraction/cdb_Sustem.h"
|
||||
#include "stdio.h"
|
||||
|
||||
void main(){
|
||||
sus_File file = sus_fileOpenInMem("testfile.txt", SUS_FILE_TEMP);
|
||||
if(file == NULL){
|
||||
printf("file is null");
|
||||
return;
|
||||
}
|
||||
|
||||
char * memroy = sus_fileFileToMemroy(file);
|
||||
if(memroy == 0){
|
||||
printf("memroy was null\n");
|
||||
return;
|
||||
}else{
|
||||
printf("%c%c%c%c", memroy[0], memroy[1], memroy[2], memroy[3]);
|
||||
}
|
||||
|
||||
sus_fileResize(file, 2);
|
||||
memroy = sus_fileFileToMemroy(file);
|
||||
memroy[0] = 'a';
|
||||
memroy[1] = 'b';
|
||||
memroy[2] = 'c';
|
||||
memroy[3] = 'd';
|
||||
memroy[4] = 'e';
|
||||
Sleep(10000);
|
||||
sus_fileFlush(file);
|
||||
sus_fileClose(file);
|
||||
file = sus_fileOpenInMem("testfile.txt", SUS_FILE_NOTHING);
|
||||
memroy = sus_fileFileToMemroy(file); //crash expected here
|
||||
memroy[0] = 'O';
|
||||
sus_fileFlush(file);
|
||||
sus_fileClose(file);
|
||||
}
|
33
tests/System Abstraction/3/openTempFiletest.c_old
Normal file
33
tests/System Abstraction/3/openTempFiletest.c_old
Normal file
@ -0,0 +1,33 @@
|
||||
#include "..\..\..\System Abstraction/cdb_Sustem.h"
|
||||
#include "stdio.h"
|
||||
|
||||
void main(){
|
||||
sus_File file = sus_fileOpenInMem("testfile.txt", SUS_FILE_NEW);
|
||||
if(file == NULL){
|
||||
printf("file is null");
|
||||
return;
|
||||
}
|
||||
|
||||
char * memroy = sus_fileFileToMemroy(file);
|
||||
if(memroy == 0){
|
||||
printf("memroy was null\n");
|
||||
return;
|
||||
}else{
|
||||
printf("%c%c%c%c", memroy[0], memroy[1], memroy[2], memroy[3]);
|
||||
}
|
||||
|
||||
sus_fileResize(file, 2);
|
||||
memroy = sus_fileFileToMemroy(file);
|
||||
memroy[0] = 'a';
|
||||
memroy[1] = 'b';
|
||||
memroy[2] = 'c';
|
||||
memroy[3] = 'd';
|
||||
memroy[4] = 'e';
|
||||
sus_fileFlush(file);
|
||||
sus_fileClose(file);
|
||||
file = sus_fileOpenInMem("testfile.txt", SUS_FILE_NOTHING);
|
||||
memroy = sus_fileFileToMemroy(file);
|
||||
memroy[0] = 'O';
|
||||
sus_fileFlush(file);
|
||||
sus_fileClose(file);
|
||||
}
|
BIN
tests/System Abstraction/3/openTempFiletest.exe
Normal file
BIN
tests/System Abstraction/3/openTempFiletest.exe
Normal file
Binary file not shown.
1
tests/System Abstraction/3/testfile2.txt
Normal file
1
tests/System Abstraction/3/testfile2.txt
Normal file
@ -0,0 +1 @@
|
||||
Obc
|
Loading…
Reference in New Issue
Block a user