You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pe...@apache.org on 2023/08/16 03:46:39 UTC

[celix] branch feature/527-manifest-improvement updated: Add more test for manifest.c

This is an automated email from the ASF dual-hosted git repository.

pengzheng pushed a commit to branch feature/527-manifest-improvement
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/feature/527-manifest-improvement by this push:
     new 7f904d88 Add more test for manifest.c
7f904d88 is described below

commit 7f904d88222b786e9a075fdde04c7dafac215b5a
Author: PengZheng <ho...@gmail.com>
AuthorDate: Wed Aug 16 11:46:30 2023 +0800

    Add more test for manifest.c
---
 libs/framework/gtest/src/ManifestTestSuite.cc | 39 +++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/libs/framework/gtest/src/ManifestTestSuite.cc b/libs/framework/gtest/src/ManifestTestSuite.cc
index bcbfce3a..51cb2bf6 100644
--- a/libs/framework/gtest/src/ManifestTestSuite.cc
+++ b/libs/framework/gtest/src/ManifestTestSuite.cc
@@ -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"