-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
66 lines (58 loc) · 1.35 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "fs/fs.h"
#include "tempdir.h"
#define CLEAR_ENV_VARS \
assert(0 == putenv("TMPDIR=/not/real")); \
assert(0 == putenv("TEMP=/not/real")); \
assert(0 == putenv("TMP=/not/real")); \
assert(0 == putenv("Wimp$ScrapDir=/not/real")); \
int
main(void) {
// test TMPDIR
{
CLEAR_ENV_VARS;
assert(0 == putenv("TMPDIR=./"));
char *dir = gettempdir();
assert(dir && 0 == strcmp("./", dir));
assert(0 == fs_exists(dir));
free(dir);
}
// test TEMP
{
CLEAR_ENV_VARS;
assert(0 == putenv("TEMP=./"));
char *dir = gettempdir();
assert(dir && 0 == strcmp("./", dir));
assert(0 == fs_exists(dir));
free(dir);
}
// test TMP
{
CLEAR_ENV_VARS;
assert(0 == putenv("TMP=./"));
char *dir = gettempdir();
assert(dir && 0 == strcmp("./", dir));
assert(0 == fs_exists(dir));
free(dir);
}
// test Wimp$ScrapDir (RiscOS)
{
CLEAR_ENV_VARS;
assert(0 == putenv("Wimp$ScrapDir=./"));
char *dir = gettempdir();
assert(dir && 0 == strcmp("./", dir));
assert(0 == fs_exists(dir));
free(dir);
}
// test platform checks / cwd
{
CLEAR_ENV_VARS;
char *dir = gettempdir();
assert(dir);
assert(0 == fs_exists(dir));
free(dir);
}
return 0;
}