[gnome-commander] Moved to glib functions str_uri_basename function and optimized unit tests
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Moved to glib functions str_uri_basename function and optimized unit tests
- Date: Sat, 1 Jul 2017 20:30:53 +0000 (UTC)
commit 98526efd0bb4e8f366b9d08807cf92c4b444c02d
Author: Uwe Scholz <uwescholz src gnome org>
Date: Sat Jul 1 22:28:17 2017 +0200
Moved to glib functions str_uri_basename function and optimized unit tests
src/utils-no-dependencies.cc | 4 ++--
tests/utils_no_dependencies_tests.cc | 17 ++++++-----------
2 files changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/src/utils-no-dependencies.cc b/src/utils-no-dependencies.cc
index 23e8f1c..84dcaca 100644
--- a/src/utils-no-dependencies.cc
+++ b/src/utils-no-dependencies.cc
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include <glib.h>
#include <string.h>
-#include <libgnomevfs/gnome-vfs.h>
#include "utils-no-dependencies.h"
@@ -39,7 +39,7 @@ gchar* str_uri_basename (const gchar *uri)
if (uri[i] == '/')
last_slash = i;
- return gnome_vfs_unescape_string (&uri[last_slash+1], NULL);
+ return g_uri_unescape_string (&uri[last_slash+1], NULL);
}
diff --git a/tests/utils_no_dependencies_tests.cc b/tests/utils_no_dependencies_tests.cc
index 15aa09a..0486cd3 100644
--- a/tests/utils_no_dependencies_tests.cc
+++ b/tests/utils_no_dependencies_tests.cc
@@ -30,24 +30,19 @@
#include "../src/utils-no-dependencies.h"
-TEST(StrUriBasename, IfNullReturnNull)
+TEST(StrUriBasename, ReturnNull)
{
EXPECT_EQ (NULL, str_uri_basename(NULL));
-}
-
-TEST(StrUriBasename, IfArgStringLengthIsShorterThanTwoBytesReturnNull)
-{
- gchar* argument;
- argument = (gchar*) "a";
- EXPECT_EQ (NULL, str_uri_basename(argument));
+ // If argument string length is shorter
+ // than two bytes return null
+ EXPECT_EQ (NULL, str_uri_basename((gchar*) "a"));
}
TEST(StrUriBasename, ReturnEscapedStringAfterLastSlash)
{
- gchar* argument;
- argument = (gchar*) "http://xyz";
- EXPECT_STREQ ("xyz", str_uri_basename(argument));
+ EXPECT_STREQ ("xyz", str_uri_basename((gchar*) "http://xyz"));
+ EXPECT_STREQ ("xyz?", str_uri_basename((gchar*) "http://xyz?"));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]