fopen and tests

This commit is contained in:
nora 2023-10-04 21:35:18 +02:00
parent 862ef8dc22
commit b795ee80c9
14 changed files with 97 additions and 45 deletions

16
tests/c/fopen.c Normal file
View file

@ -0,0 +1,16 @@
#include <stdio.h>
#include <errno.h>
#include <assert.h>
int main(int argc, char *argv[]) {
FILE *file1 = fopen("./c/fopen.c", "r");
assert(file1 && "failed to open file");
FILE *file2 = fopen("./c/fopen.c", "meow");
assert(!file2 && "succeeded opening file despite invalid argument");
assert((errno == EINVAL) && "wrong errno");
FILE *file3 = fopen("/this-does-absolutely-not-exist-at-all-edhjkefhew98", "r");
assert(!file3 && "succeeded despite file not existing");
assert((errno == ENOENT) && "wrong errno");
}