]> granicus.if.org Git - neomutt/commitdiff
test: improve test_mutt_str_strcat()
authorRichard Russon <rich@flatcap.org>
Sun, 26 May 2019 15:02:24 +0000 (16:02 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 26 May 2019 16:18:13 +0000 (17:18 +0100)
mutt/string.c
test/string/mutt_str_strcat.c

index 9f84d448003fcb8522e97f930d83b8856f748ee0..21c8cb16e961ceb2a629d2801f36826d68e64509 100644 (file)
@@ -394,7 +394,7 @@ char *mutt_str_strdup(const char *str)
  * @param buf    Buffer containing source string
  * @param buflen Length of buffer
  * @param s      String to add
- * @retval ptr Start of joined string
+ * @retval ptr Start of the buffer
  */
 char *mutt_str_strcat(char *buf, size_t buflen, const char *s)
 {
index dd5313d11c8aedef1380fa4609de9374f0c91dac..d1ce6f571979e561fac4837a822bd1287065d049 100644 (file)
@@ -33,8 +33,38 @@ void test_mutt_str_strcat(void)
     TEST_CHECK(mutt_str_strcat(NULL, 10, "apple") == NULL);
   }
 
+  {
+    char buf[64] = { 0 };
+    TEST_CHECK(mutt_str_strcat(buf, 0, "apple") == buf);
+    TEST_CHECK(strcmp(buf, "") == 0);
+  }
+
   {
     char buf[32] = { 0 };
     TEST_CHECK(mutt_str_strcat(buf, sizeof(buf), NULL) == buf);
   }
+
+  {
+    char buf[32] = { 0 };
+    TEST_CHECK(mutt_str_strcat(buf, sizeof(buf), "") == buf);
+    TEST_CHECK(strcmp(buf, "") == 0);
+  }
+
+  {
+    char buf[32] = { 0 };
+    TEST_CHECK(mutt_str_strcat(buf, sizeof(buf), "banana") == buf);
+    TEST_CHECK(strcmp(buf, "banana") == 0);
+  }
+
+  {
+    char buf[32] = "apple";
+    TEST_CHECK(mutt_str_strcat(buf, sizeof(buf), "") == buf);
+    TEST_CHECK(strcmp(buf, "apple") == 0);
+  }
+
+  {
+    char buf[32] = "apple";
+    TEST_CHECK(mutt_str_strcat(buf, sizeof(buf), "banana") == buf);
+    TEST_CHECK(strcmp(buf, "applebanana") == 0);
+  }
 }