]> git.saurik.com Git - apt.git/blob - test/libapt/tagfile_test.cc
add REAMDE.md
[apt.git] / test / libapt / tagfile_test.cc
1 #include <config.h>
2
3 #include <apt-pkg/fileutl.h>
4 #include <apt-pkg/tagfile.h>
5
6 #include <string>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <unistd.h>
10
11 #include <gtest/gtest.h>
12
13 #include "file-helpers.h"
14
15 TEST(TagFileTest,SingleField)
16 {
17 FileFd fd;
18 createTemporaryFile("singlefield", fd, NULL, "FieldA-12345678: the value of the field");
19
20 pkgTagFile tfile(&fd);
21 pkgTagSection section;
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));
36 }