]>
git.saurik.com Git - apt.git/blob - test/libapt/sourcelist_test.cc
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 "URI: http://ftp.debian.org/debian\n"
29 "Comment: Some random string\n"
30 " that can be very long\n"
33 "URI: http://ftp.debian.org/debian\n"
35 "Section: main non-free\n"
39 atexit(remove_tmpfile
);
40 tempfile
= strdup("apt-test.XXXXXXXX");
41 tempfile_fd
= mkstemp(tempfile
);
43 /* (Re-)Open (as FileFd), write and seek to start of the temp file */
44 equals(fd
.OpenDescriptor(tempfile_fd
, FileFd::ReadWrite
), true);
45 equals(fd
.Write(contents
, strlen(contents
)), true);
46 equals(fd
.Seek(0), true);
48 pkgSourceList
sources(tempfile
);
49 equals(sources
.size(), 2);
51 /* clean up handled by atexit handler, so just return here */