]>
git.saurik.com Git - apt.git/blob - test/libapt/tagfile_test.cc
3 #include <apt-pkg/fileutl.h>
4 #include <apt-pkg/tagfile.h>
11 #include <gtest/gtest.h>
13 #include "file-helpers.h"
15 TEST(TagFileTest
,SingleField
)
18 createTemporaryFile("singlefield", fd
, NULL
, "FieldA-12345678: the value of the field");
20 pkgTagFile
tfile(&fd
);
21 pkgTagSection section
;
22 ASSERT_TRUE(tfile
.Step(section
));
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
));