]> git.saurik.com Git - apt.git/blame - test/libapt/tagfile_test.cc
Merge remote-tracking branch 'upstream/debian/sid' into debian/sid
[apt.git] / test / libapt / tagfile_test.cc
CommitLineData
453b82a3
DK
1#include <config.h>
2
c8b860fb
MV
3#include <apt-pkg/fileutl.h>
4#include <apt-pkg/tagfile.h>
5
453b82a3 6#include <string>
c8b860fb
MV
7#include <stdlib.h>
8#include <string.h>
0c98ee5a 9#include <unistd.h>
c8b860fb 10
f00832cc 11#include <gtest/gtest.h>
453b82a3 12
f00832cc 13#include "file-helpers.h"
c8b860fb 14
f00832cc 15TEST(TagFileTest,SingleField)
c8b860fb
MV
16{
17 FileFd fd;
f00832cc 18 createTemporaryFile("singlefield", fd, NULL, "FieldA-12345678: the value of the field");
c8b860fb
MV
19
20 pkgTagFile tfile(&fd);
21 pkgTagSection section;
f00832cc
DK
22 ASSERT_TRUE(tfile.Step(section));
23
24 // It has one field
25 EXPECT_EQ(1, section.Count());
26 // ... and it is called FieldA-12345678
27 EXPECT_TRUE(section.Exists("FieldA-12345678"));
28 // its value is correct
29 EXPECT_EQ("the value of the field", section.FindS("FieldA-12345678"));
30 // A non-existent field has an empty string as value
31 EXPECT_EQ("", section.FindS("FieldB-12345678"));
32 // ... and Exists does not lie about missing fields...
33 EXPECT_FALSE(section.Exists("FieldB-12345678"));
34 // There is only one section in this tag file
35 EXPECT_FALSE(tfile.Step(section));
c8b860fb 36}