]> granicus.if.org Git - neomutt/commitdiff
test: improve test_mutt_buffer_strcpy()
authorRichard Russon <rich@flatcap.org>
Fri, 24 May 2019 22:24:04 +0000 (23:24 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 26 May 2019 16:16:51 +0000 (17:16 +0100)
test/buffer/mutt_buffer_strcpy.c

index 5b916d3971a7413b9b53c0b5323b675ad213ad70..06a720f5e3511321ffae5d13ab62e2b4d07f21f9 100644 (file)
@@ -39,4 +39,42 @@ void test_mutt_buffer_strcpy(void)
     mutt_buffer_strcpy(&buf, NULL);
     TEST_CHECK_(1, "mutt_buffer_strcpy(&buf, NULL)");
   }
+
+  TEST_CASE("Copy to an empty Buffer");
+
+  {
+    TEST_CASE("Empty");
+    struct Buffer *buf = mutt_buffer_new();
+    mutt_buffer_strcpy(buf, "");
+    TEST_CHECK(strcmp(mutt_b2s(buf), "") == 0);
+    mutt_buffer_free(&buf);
+  }
+
+  {
+    TEST_CASE("String");
+    const char *str = "test";
+    struct Buffer *buf = mutt_buffer_new();
+    mutt_buffer_strcpy(buf, str);
+    TEST_CHECK(strcmp(mutt_b2s(buf), str) == 0);
+    mutt_buffer_free(&buf);
+  }
+
+  TEST_CASE("Overwrite a non-empty Buffer");
+
+  {
+    TEST_CASE("Empty");
+    struct Buffer *buf = mutt_buffer_from("test");
+    mutt_buffer_strcpy(buf, "");
+    TEST_CHECK(strcmp(mutt_b2s(buf), "") == 0);
+    mutt_buffer_free(&buf);
+  }
+
+  {
+    TEST_CASE("String");
+    const char *str = "apple";
+    struct Buffer *buf = mutt_buffer_from("test");
+    mutt_buffer_strcpy(buf, str);
+    TEST_CHECK(strcmp(mutt_b2s(buf), str) == 0);
+    mutt_buffer_free(&buf);
+  }
 }