Skip to content

Commit

Permalink
Add more test for manifest.c
Browse files Browse the repository at this point in the history
  • Loading branch information
PengZheng committed Aug 16, 2023
1 parent 844f325 commit 7f904d8
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions libs/framework/gtest/src/ManifestTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,45 @@ TEST_F(ManifestTestSuite, ReadManifestWithoutNameSectionsTest) {
EXPECT_EQ(0, hashMap_size(entries));
}

TEST_F(ManifestTestSuite, ReadManifestWithCarriageReturnTest) {
std::string content = "Manifest-Version: 1.0\r\n"
"DeploymentPackage-SymbolicName: com.third._3d\r\n"
"DeploymentPacakge-Version: 1.2.3.build22032005\r\n"
"DeploymentPackage-Copyright: ACME Inc. (c) 2003\r\n";
celix_autoptr(FILE) manifestFile = fmemopen((void*)content.c_str(), content.size(), "r");
EXPECT_EQ(CELIX_SUCCESS, manifest_readFromStream(manifest, manifestFile));
const celix_properties_t* mainAttr = manifest_getMainAttributes(manifest);
EXPECT_EQ(4, celix_properties_size(mainAttr));
EXPECT_STREQ("1.0", celix_properties_get(mainAttr, "Manifest-Version", nullptr));
EXPECT_STREQ("com.third._3d", celix_properties_get(mainAttr, "DeploymentPackage-SymbolicName", nullptr));
EXPECT_STREQ("1.2.3.build22032005", celix_properties_get(mainAttr, "DeploymentPacakge-Version", nullptr));
EXPECT_STREQ("ACME Inc. (c) 2003", celix_properties_get(mainAttr, "DeploymentPackage-Copyright", nullptr));
hash_map_pt entries = nullptr;
EXPECT_EQ(CELIX_SUCCESS, manifest_getEntries(manifest, &entries));
EXPECT_NE(nullptr, entries);
EXPECT_EQ(0, hashMap_size(entries));
}

TEST_F(ManifestTestSuite, ReadManifestWithLineContinuationTest) {
std::string content = "Manifest-Version: 1.0\n"
"DeploymentPackage-SymbolicName: com.third._3d\n"
" x\n" /* line continuation */
"DeploymentPacakge-Version: 1.2.3.build22032005\n"
"DeploymentPackage-Copyright: ACME Inc. (c) 2003\n";
celix_autoptr(FILE) manifestFile = fmemopen((void*)content.c_str(), content.size(), "r");
EXPECT_EQ(CELIX_SUCCESS, manifest_readFromStream(manifest, manifestFile));
const celix_properties_t* mainAttr = manifest_getMainAttributes(manifest);
EXPECT_EQ(4, celix_properties_size(mainAttr));
EXPECT_STREQ("1.0", celix_properties_get(mainAttr, "Manifest-Version", nullptr));
EXPECT_STREQ("com.third._3dx", celix_properties_get(mainAttr, "DeploymentPackage-SymbolicName", nullptr));
EXPECT_STREQ("1.2.3.build22032005", celix_properties_get(mainAttr, "DeploymentPacakge-Version", nullptr));
EXPECT_STREQ("ACME Inc. (c) 2003", celix_properties_get(mainAttr, "DeploymentPackage-Copyright", nullptr));
hash_map_pt entries = nullptr;
EXPECT_EQ(CELIX_SUCCESS, manifest_getEntries(manifest, &entries));
EXPECT_NE(nullptr, entries);
EXPECT_EQ(0, hashMap_size(entries));
}

TEST_F(ManifestTestSuite, ReadManifestWithoutNewlineInLastLineTest) {
std::string content = "Manifest-Version: 1.0\n"
"DeploymentPackage-SymbolicName: com.third._3d\n"
Expand Down

0 comments on commit 7f904d8

Please sign in to comment.