]>
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 "URIs: http://ftp.debian.org/debian\n"
29 "Description: short\n"
30 " long description that can be very long\n"
33 "URIs: http://ftp.debian.org/debian\n"
35 "Sections: 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 */