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