some unit tests for da system abstraction layer

sus
This commit is contained in:
The Arrayser 2022-08-28 13:47:31 +02:00 committed by GitHub
parent b6564966cf
commit 223210bf4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 139 additions and 0 deletions

View File

@ -0,0 +1 @@
gcc.exe systemAbstractionTest1.c "../../../System Abstraction/win32/cdb_file.c" "../../../System Abstraction/win32/cdb_memroy.c" -o systemAbstractionTest1.exe

View 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);
}

Binary file not shown.

View File

@ -0,0 +1 @@
Obc

View File

@ -0,0 +1 @@
gcc.exe openNewFiletest.c "../../../System Abstraction/win32/cdb_file.c" "../../../System Abstraction/win32/cdb_memroy.c" -o systemAbstractionTest1.exe

View 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);
}

Binary file not shown.

View File

@ -0,0 +1 @@
Obc

View File

View File

@ -0,0 +1 @@
gcc.exe openTempFiletest.c "../../../System Abstraction/win32/cdb_file.c" "../../../System Abstraction/win32/cdb_memroy.c" -o openTempFiletest.exe

View 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);
}

View 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);
}

Binary file not shown.

View File

@ -0,0 +1 @@
Obc