]> granicus.if.org Git - neomutt/commitdiff
test: add path tests for degenerate cases
authorRichard Russon <rich@flatcap.org>
Fri, 19 Apr 2019 00:07:37 +0000 (01:07 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 24 Apr 2019 11:16:16 +0000 (12:16 +0100)
15 files changed:
test/path/mutt_path_abbr_folder.c
test/path/mutt_path_basename.c
test/path/mutt_path_canon.c
test/path/mutt_path_concat.c
test/path/mutt_path_concatn.c
test/path/mutt_path_dirname.c
test/path/mutt_path_escape.c
test/path/mutt_path_getcwd.c
test/path/mutt_path_parent.c
test/path/mutt_path_pretty.c
test/path/mutt_path_realpath.c
test/path/mutt_path_tidy.c
test/path/mutt_path_tidy_dotdot.c
test/path/mutt_path_tidy_slash.c
test/path/mutt_path_to_absolute.c

index 758af4dfdedb1ed5f63a69334172e6cf04d4ab24..9a05439ae81f2e9d9227a7d93726491bf5b622dd 100644 (file)
 void test_mutt_path_abbr_folder(void)
 {
   // bool mutt_path_abbr_folder(char *buf, size_t buflen, const char *folder);
+
+  {
+    TEST_CHECK(!mutt_path_abbr_folder(NULL, 10, "apple"));
+  }
+
+  {
+    char buf[32] = { 0 };
+    TEST_CHECK(!mutt_path_abbr_folder(buf, sizeof(buf), NULL));
+  }
 }
index f8886cb401fc6fda24519e535b6a726b902d0a76..3815796b5b966ba0a43741ca407d082869947bb6 100644 (file)
@@ -28,4 +28,9 @@
 void test_mutt_path_basename(void)
 {
   // const char *mutt_path_basename(const char *f);
+
+  {
+    mutt_path_basename(NULL);
+    TEST_CHECK_(1, "mutt_path_basename(NULL)");
+  }
 }
index 89f2548fbe951b55e6a9a37d3e1f414bf8060738..90b264cc68ba839db35e2a3641f1a1bdddadd6e1 100644 (file)
@@ -28,4 +28,8 @@
 void test_mutt_path_canon(void)
 {
   // bool mutt_path_canon(char *buf, size_t buflen, const char *homedir);
+
+  {
+    TEST_CHECK(!mutt_path_canon(NULL, 10, "apple"));
+  }
 }
index e5a74e6f219d478e922bdee06a4dd2c27a8ab873..14a2ec3e0b8885ebb597e5541208dbe21696c97c 100644 (file)
 void test_mutt_path_concat(void)
 {
   // char *mutt_path_concat(char *d, const char *dir, const char *fname, size_t l);
+
+  {
+    TEST_CHECK(mutt_path_concat(NULL, "apple", "banana", 5) == NULL);
+  }
+
+  {
+    char buf[32] = { 0 };
+    TEST_CHECK(mutt_path_concat(buf, NULL, "banana", 5) == NULL);
+  }
+
+  {
+    char buf[32] = { 0 };
+    TEST_CHECK(mutt_path_concat(buf, "apple", NULL, 5) == NULL);
+  }
 }
index e866a2fe6ba16d302a45c48f96ad5b05c8a11c2f..f8d247e019bf0726118a852adf400259ba93a777 100644 (file)
 void test_mutt_path_concatn(void)
 {
   // char *mutt_path_concatn(char *dst, size_t dstlen, const char *dir, size_t dirlen, const char *fname, size_t fnamelen);
+
+  {
+    TEST_CHECK(mutt_path_concatn(NULL, 10, "apple", 5, "banana", 6) == NULL);
+  }
+
+  {
+    char buf[32] = { 0 };
+    TEST_CHECK(mutt_path_concatn(buf, sizeof(buf), NULL, 5, "banana", 6) == NULL);
+  }
+
+  {
+    char buf[32] = { 0 };
+    TEST_CHECK(mutt_path_concatn(buf, sizeof(buf), "apple", 5, NULL, 6) == NULL);
+  }
 }
index 0fae79e428aac79704f4823657680f7b186127df..2decd0c66334d4dd096d9b24c4bd170713a14499 100644 (file)
@@ -28,4 +28,8 @@
 void test_mutt_path_dirname(void)
 {
   // char *mutt_path_dirname(const char *path);
+
+  {
+    TEST_CHECK(mutt_path_dirname(NULL) == NULL);
+  }
 }
index 99874d49e667a395a2f22f6cde451be6d6872ea7..378a134cb2ba0c9f2db423fbd16c77f68ae53964 100644 (file)
@@ -28,4 +28,8 @@
 void test_mutt_path_escape(void)
 {
   // char *mutt_path_escape(const char *src);
+
+  {
+    TEST_CHECK(mutt_path_escape(NULL) == NULL);
+  }
 }
index 3e9ac5d125a2889dcc02e7de1c610bb038e852e1..5f3e69af62ef84638acfff1fbfed85c5bd4aaa65 100644 (file)
@@ -28,4 +28,9 @@
 void test_mutt_path_getcwd(void)
 {
   // void mutt_path_getcwd(struct Buffer *cwd);
+
+  {
+    mutt_path_getcwd(NULL);
+    TEST_CHECK_(1, "mutt_path_getcwd(NULL)");
+  }
 }
index 0a0468fa50fc80c08ab8bee698a40c5081e7df5e..e166bdc24e75095a5f6321a2e30f862a496f6378 100644 (file)
@@ -28,4 +28,8 @@
 void test_mutt_path_parent(void)
 {
   // bool mutt_path_parent(char *buf, size_t buflen);
+
+  {
+    TEST_CHECK(!mutt_path_parent(NULL, 10));
+  }
 }
index 8b2f817a4ce8e95e3ffc5dd3caf4853b2220b209..a37f92566bd091935fdaa6564c4d55ad353625c9 100644 (file)
 void test_mutt_path_pretty(void)
 {
   // bool mutt_path_pretty(char *buf, size_t buflen, const char *homedir);
+
+  {
+    TEST_CHECK(!mutt_path_pretty(NULL, 10, "apple"));
+  }
+
+  {
+    char buf[32] = { 0 };
+    TEST_CHECK(!mutt_path_pretty(buf, sizeof(buf), NULL));
+  }
 }
index 165d8c3639fc16a59e38ef9d69b08177c2d7a193..ecd69bd56606a83aa99586cb3b1ab182504d9888 100644 (file)
@@ -28,4 +28,8 @@
 void test_mutt_path_realpath(void)
 {
   // size_t mutt_path_realpath(char *buf);
+
+  {
+    TEST_CHECK(mutt_path_realpath(NULL) == 0);
+  }
 }
index 562a936a49f53ff365d9c9ff7653d094145ffe7f..061b3aadb2ae5c2e04cc3297bc1c7582cf47cae6 100644 (file)
@@ -28,4 +28,8 @@
 void test_mutt_path_tidy(void)
 {
   // bool mutt_path_tidy(char *buf);
+
+  {
+    TEST_CHECK(!mutt_path_tidy(NULL));
+  }
 }
index de0822fb18049f43a596f3608fe7edbe41357179..afdbe23c5a0a658a6cdd6f84b37eab41ceec24f4 100644 (file)
@@ -28,4 +28,8 @@
 void test_mutt_path_tidy_dotdot(void)
 {
   // bool mutt_path_tidy_dotdot(char *buf);
+
+  {
+    TEST_CHECK(!mutt_path_tidy_dotdot(NULL));
+  }
 }
index 3ace0e84c83d0b36604a48dfed29239adcd66651..c02338aef7fc55eb8a677e52bf2e35f83724e69b 100644 (file)
@@ -28,4 +28,8 @@
 void test_mutt_path_tidy_slash(void)
 {
   // bool mutt_path_tidy_slash(char *buf);
+
+  {
+    TEST_CHECK(!mutt_path_tidy_slash(NULL));
+  }
 }
index 06d38a9a3cef2e2dd6a9dd11e29dd77660974d2d..d29d06b9dc98a49bd98e62ba3773d9d7016aaad9 100644 (file)
 void test_mutt_path_to_absolute(void)
 {
   // int mutt_path_to_absolute(char *path, const char *reference);
+
+  {
+    TEST_CHECK(!mutt_path_to_absolute(NULL, "apple"));
+  }
+
+  {
+    TEST_CHECK(!mutt_path_to_absolute("apple", NULL));
+  }
 }