]> granicus.if.org Git - neomutt/commitdiff
test: improve test_mutt_str_dequote_comment()
authorRichard Russon <rich@flatcap.org>
Sun, 26 May 2019 15:02:23 +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_dequote_comment.c

index fc2a08fe360efc2fd6d3dc073b9b4a9ac93d8ecf..87fbc5395aa7415880e04ff3aa103ff36b7912bf 100644 (file)
@@ -878,7 +878,7 @@ size_t mutt_str_lws_rlen(const char *s, size_t n)
 
 /**
  * mutt_str_dequote_comment - Un-escape characters in an email address comment
- * @param s String to the un-escaped
+ * @param s String to be un-escaped
  *
  * @note The string is changed in-place
  */
index ab6d2a79b93f64416c615688a394728bfa7db71e..eeafc2848bd5ac77b8d9a14b667cd495e841845c 100644 (file)
@@ -33,4 +33,43 @@ void test_mutt_str_dequote_comment(void)
     mutt_str_dequote_comment(NULL);
     TEST_CHECK_(1, "mutt_str_dequote_comment(NULL)");
   }
+
+  {
+    const char *str = "hello";
+    char *dequote = strdup(str);
+    mutt_str_dequote_comment(dequote);
+    TEST_CHECK_(1, "mutt_str_dequote_comment(dequote)");
+    TEST_CHECK(strcmp(dequote, str) == 0);
+    FREE(&dequote);
+  }
+
+  {
+    const char *str = "he\"ll\"o";
+    const char *expected = "hello";
+    char *dequote = strdup(str);
+    mutt_str_dequote_comment(dequote);
+    TEST_CHECK_(1, "mutt_str_dequote_comment(dequote)");
+    TEST_CHECK(strcmp(dequote, expected) == 0);
+    FREE(&dequote);
+  }
+
+  {
+    const char *str = "he\\ll\\o";
+    const char *expected = "hello";
+    char *dequote = strdup(str);
+    mutt_str_dequote_comment(dequote);
+    TEST_CHECK_(1, "mutt_str_dequote_comment(dequote)");
+    TEST_CHECK(strcmp(dequote, expected) == 0);
+    FREE(&dequote);
+  }
+
+  {
+    const char *str = "he\\llo\\";
+    const char *expected = "hello";
+    char *dequote = strdup(str);
+    mutt_str_dequote_comment(dequote);
+    TEST_CHECK_(1, "mutt_str_dequote_comment(dequote)");
+    TEST_CHECK(strcmp(dequote, expected) == 0);
+    FREE(&dequote);
+  }
 }