]> git.saurik.com Git - apt.git/blame - test/libapt/fileutl_test.cc
Merge branch 'debian/sid' into feature/more-fancy-progress
[apt.git] / test / libapt / fileutl_test.cc
CommitLineData
453b82a3
DK
1#include <config.h>
2
488011fa
MV
3#include <apt-pkg/error.h>
4#include <apt-pkg/fileutl.h>
5
488011fa
MV
6#include <string>
7#include <vector>
488011fa
MV
8#include <stdlib.h>
9
453b82a3 10#include "assert.h"
488011fa 11
65512241 12int main()
488011fa
MV
13{
14 std::vector<std::string> files;
15
16 // normal match
17 files = Glob("*.lst");
18 if (files.size() != 1)
19 {
20 _error->DumpErrors();
21 return 1;
22 }
23
24 // not there
25 files = Glob("xxxyyyzzz");
26 if (files.size() != 0 || _error->PendingError())
27 {
28 _error->DumpErrors();
29 return 1;
30 }
31
32 // many matches (number is a bit random)
33 files = Glob("*.cc");
34 if (files.size() < 10)
35 {
36 _error->DumpErrors();
37 return 1;
38 }
39
a077861a
MV
40 // GetTempDir()
41 unsetenv("TMPDIR");
42 equals(GetTempDir(), "/tmp");
43
44 setenv("TMPDIR", "", 1);
45 equals(GetTempDir(), "/tmp");
46
47 setenv("TMPDIR", "/not-there-no-really-not", 1);
48 equals(GetTempDir(), "/tmp");
49
50 setenv("TMPDIR", "/usr", 1);
51 equals(GetTempDir(), "/usr");
52
488011fa
MV
53 return 0;
54}