[Common/Test] minor update
authorJaeyun <jy1210.jung@samsung.com>
Wed, 12 Jun 2019 03:33:44 +0000 (12:33 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Fri, 14 Jun 2019 06:57:02 +0000 (15:57 +0900)
1. check string len while checking data type.
2. unref pad instance in testcases.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
gst/nnstreamer/tensor_common.c
tests/common/unittest_common.cpp
tests/nnstreamer_sink/unittest_sink.cpp

index 1351147..08896fb 100644 (file)
@@ -967,6 +967,11 @@ gst_tensor_get_type (const gchar * typestr)
 
   len = strlen (type_string);
 
+  if (len == 0) {
+    g_free (type_string);
+    return _NNS_END;
+  }
+
   if (type_string[0] == 'u' || type_string[0] == 'U') {
     /**
      * Let's believe the developer and the following three letters are "int"
index 9c40cef..6603f1d 100644 (file)
@@ -31,6 +31,7 @@ TEST (common_get_tensor_type, int32)
   EXPECT_EQ (gst_tensor_get_type ("InT32"), _NNS_INT32);
   EXPECT_EQ (gst_tensor_get_type ("InT322"), _NNS_END);
   EXPECT_EQ (gst_tensor_get_type ("int3"), _NNS_END);
+  EXPECT_EQ (gst_tensor_get_type (""), _NNS_END);
 }
 
 /**
index a596cfb..6e61569 100644 (file)
@@ -304,6 +304,7 @@ _new_data_cb (GstElement * element, GstBuffer * buffer, gpointer user_data)
     /** copy current caps */
     g_test_data.current_caps = gst_caps_copy (caps);
     gst_caps_unref (caps);
+    gst_object_unref (sink_pad);
   }
 }