]>
git.saurik.com Git - apt.git/blob - test/libapt/sourcelist_test.cc
6e83d08e022f6fa2a719c25a9671be4684e99e29
1 #include <apt-pkg/sourcelist.h>
2 #include <apt-pkg/tagfile.h>
12 void remove_tmpfile(void)
16 if (tempfile
!= NULL
) {
22 int main(int argc
, char *argv
[])
24 const char contents
[] = ""
26 "URL: http://ftp.debian.org/debian\n"
29 "Comment: Some random string\n"
30 " that can be very long\n"
33 "URL: http://ftp.debian.org/debian\n"
35 "Section: main non-free\n"
39 tempfile
= strdup("apt-test.XXXXXXXX");
40 tempfile_fd
= mkstemp(tempfile
);
42 /* (Re-)Open (as FileFd), write and seek to start of the temp file */
43 equals(fd
.OpenDescriptor(tempfile_fd
, FileFd::ReadWrite
), true);
44 equals(fd
.Write(contents
, strlen(contents
)), true);
45 equals(fd
.Seek(0), true);
47 pkgSourceList
sources(tempfile
);
48 equals(sources
.size(), 2);
50 /* clean up handled by atexit handler, so just return here */