[gnome-commander] Adds unit tests for str_uri_basename(const gchar* uri)



commit d9c783ab0a62f7d33bb319d5a0772ea15136b5ce
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Fri Jun 30 23:56:15 2017 +0200

    Adds unit tests for str_uri_basename(const gchar* uri)

 src/utils-no-dependencies.cc         |    2 +-
 tests/utils_no_dependencies_tests.cc |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/utils-no-dependencies.cc b/src/utils-no-dependencies.cc
index 48bccdf..23e8f1c 100644
--- a/src/utils-no-dependencies.cc
+++ b/src/utils-no-dependencies.cc
@@ -35,7 +35,7 @@ gchar* str_uri_basename (const gchar *uri)
 
     int last_slash = 0;
 
-    for (int i=0; i<len; i++)
+    for (int i = 0; i < len; i++)
         if (uri[i] == '/')
             last_slash = i;
 
diff --git a/tests/utils_no_dependencies_tests.cc b/tests/utils_no_dependencies_tests.cc
index fecb06b..15aa09a 100644
--- a/tests/utils_no_dependencies_tests.cc
+++ b/tests/utils_no_dependencies_tests.cc
@@ -34,3 +34,20 @@ TEST(StrUriBasename, IfNullReturnNull)
 {
     EXPECT_EQ (NULL, str_uri_basename(NULL));
 }
+
+
+TEST(StrUriBasename, IfArgStringLengthIsShorterThanTwoBytesReturnNull)
+{
+    gchar* argument;
+    argument = (gchar*) "a";
+    EXPECT_EQ (NULL, str_uri_basename(argument));
+}
+
+
+TEST(StrUriBasename, ReturnEscapedStringAfterLastSlash)
+{
+    gchar* argument;
+    argument = (gchar*) "http://xyz";;
+    EXPECT_STREQ ("xyz", str_uri_basename(argument));
+}
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]