Add IsEmpty() method 27/236127/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Mon, 15 Jun 2020 06:25:19 +0000 (15:25 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Mon, 15 Jun 2020 06:25:19 +0000 (15:25 +0900)
Change-Id: Id7a36a8f2f7ac5079c731ce8fb46ae5d7e2529b1
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
include/bundle_cpp.h
src/bundle_cpp.cc
unit_tests/src/test_bundle.cc

index d95a2410349fa11a2b33c4dbf2615dae1ca7a0a2..bcab268a28527535296bd789bda8ac136bd13d6d 100644 (file)
@@ -191,6 +191,13 @@ class EXPORT_API Bundle final {
    */
   Bundle& operator = (Bundle&& b) noexcept;
 
+  /**
+   * @brief Check the bundle is empty or not.
+   * @since_tizen 6.0
+   * @return true if the bundle is empty
+   */
+  bool IsEmpty() const noexcept;
+
   /**
    * @brief Gets keys in bundle object.
    * @since_tizen 5.5
index 2d3233a489c481704f77fcc41775da571cdfabd8..6d1163cba44aaa31f1bdbbe1be9eab998b49c1a2 100644 (file)
@@ -170,6 +170,10 @@ Bundle& Bundle::operator = (Bundle&& b) noexcept {
   return *this;
 }
 
+bool Bundle::IsEmpty() const noexcept {
+  return (bundle_get_count(impl_->handle_) == 0) ? true : false;
+}
+
 std::vector<Bundle::KeyInfo> Bundle::GetKeys() {
   std::vector<Bundle::KeyInfo> v;
 
index 0ac882716ff7ec085e32aafb51674179d35243b5..c94b08059adca088289cbc66d7355c16cc355efe 100644 (file)
@@ -154,3 +154,10 @@ TEST(Bundle, GetKeysMove) {
     EXPECT_EQ(copied.GetName(), name);
   }
 }
+
+TEST(Bundle, IsEmpty) {
+  Bundle bundle;
+  EXPECT_TRUE(bundle.IsEmpty());
+  bundle.Add("TestKey1", "TestVal");
+  EXPECT_FALSE(bundle.IsEmpty());
+}