]> granicus.if.org Git - neomutt/commitdiff
test: templates for memory functions
authorRichard Russon <rich@flatcap.org>
Sun, 28 Apr 2019 11:37:15 +0000 (12:37 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 30 Apr 2019 10:22:04 +0000 (11:22 +0100)
.gitignore
test/Makefile.autosetup
test/memory/main.c [new file with mode: 0644]
test/memory/mutt_mem_calloc.c [new file with mode: 0644]
test/memory/mutt_mem_free.c [new file with mode: 0644]
test/memory/mutt_mem_malloc.c [new file with mode: 0644]
test/memory/mutt_mem_realloc.c [new file with mode: 0644]

index e3c9f04f7ca3601454683648b3b957de8b133a75..52a50eee0f76f0c142ea41f9d082693bdeaeea41 100644 (file)
@@ -27,6 +27,7 @@ test/logging-test
 test/mapping-test
 test/mbyte-test
 test/md5-test
+test/memory-test
 test/neomutt-test
 test/path-test
 test/pattern-test
index 5d3eea02c2c11fbe3ffb46047c381153401d124e..8d6d0f581840bb95994cf6b89ca03308b558cc76 100644 (file)
@@ -260,6 +260,12 @@ MD5_OBJS   = test/md5/main.o \
                  test/md5/mutt_md5_process.o \
                  test/md5/mutt_md5_toascii.o
 
+MEMORY_OBJS    = test/memory/main.o \
+                 test/memory/mutt_mem_calloc.o \
+                 test/memory/mutt_mem_free.o \
+                 test/memory/mutt_mem_malloc.o \
+                 test/memory/mutt_mem_realloc.o
+
 PATH_OBJS      = test/path/main.o \
                  test/path/mutt_path_abbr_folder.o \
                  test/path/mutt_path_basename.o \
@@ -369,6 +375,8 @@ TEST_MBYTE = test/mbyte-test$(EXEEXT)
 
 TEST_MD5 = test/md5-test$(EXEEXT)
 
+TEST_MEMORY = test/memory-test$(EXEEXT)
+
 TEST_PATH = test/path-test$(EXEEXT)
 
 TEST_PATTERN = test/pattern-test$(EXEEXT)
@@ -376,7 +384,7 @@ TEST_PATTERN = test/pattern-test$(EXEEXT)
 TEST_STRING = test/string-test$(EXEEXT)
 
 .PHONY: test
-test: $(TEST_BINARY) $(TEST_ADDRESS) $(TEST_BASE64) $(TEST_BUFFER) $(TEST_CHARSET) $(TEST_CONFIG) $(TEST_DATE) $(TEST_ENVLIST) $(TEST_FILE) $(TEST_GROUP) $(TEST_HASH) $(TEST_HISTORY) $(TEST_IDNA) $(TEST_LIST) $(TEST_LOGGING) $(TEST_MAPPING) $(TEST_MBYTE) $(TEST_MD5) $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING)
+test: $(TEST_BINARY) $(TEST_ADDRESS) $(TEST_BASE64) $(TEST_BUFFER) $(TEST_CHARSET) $(TEST_CONFIG) $(TEST_DATE) $(TEST_ENVLIST) $(TEST_FILE) $(TEST_GROUP) $(TEST_HASH) $(TEST_HISTORY) $(TEST_IDNA) $(TEST_LIST) $(TEST_LOGGING) $(TEST_MAPPING) $(TEST_MBYTE) $(TEST_MD5) $(TEST_MEMORY) $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING)
        $(TEST_BINARY)
        $(TEST_ADDRESS)
        $(TEST_BASE64)
@@ -394,6 +402,7 @@ test: $(TEST_BINARY) $(TEST_ADDRESS) $(TEST_BASE64) $(TEST_BUFFER) $(TEST_CHARSE
        $(TEST_MAPPING)
        $(TEST_MBYTE)
        $(TEST_MD5)
+       $(TEST_MEMORY)
        $(TEST_PATH)
        $(TEST_PATTERN)
        $(TEST_STRING)
@@ -452,6 +461,9 @@ $(TEST_MBYTE): $(PWD)/test/mbyte $(MBYTE_OBJS) $(MUTTLIBS)
 $(TEST_MD5): $(PWD)/test/md5 $(MD5_OBJS) $(MUTTLIBS)
        $(CC) -o $@ $(MD5_OBJS) $(MUTTLIBS) $(LDFLAGS) $(LIBS)
 
+$(TEST_MEMORY): $(PWD)/test/memory $(MEMORY_OBJS) $(MUTTLIBS)
+       $(CC) -o $@ $(MEMORY_OBJS) $(MUTTLIBS) $(LDFLAGS) $(LIBS)
+
 $(TEST_PATH): $(PWD)/test/path $(PATH_OBJS) $(MUTTLIBS)
        $(CC) -o $@ $(PATH_OBJS) $(MUTTLIBS) $(LDFLAGS) $(LIBS)
 
@@ -512,6 +524,9 @@ $(PWD)/test/mbyte:
 $(PWD)/test/md5:
        $(MKDIR_P) $(PWD)/test/md5
 
+$(PWD)/test/memory:
+       $(MKDIR_P) $(PWD)/test/memory
+
 $(PWD)/test/path:
        $(MKDIR_P) $(PWD)/test/path
 
@@ -521,7 +536,7 @@ $(PWD)/test/pattern:
 $(PWD)/test/string:
        $(MKDIR_P) $(PWD)/test/string
 
-all-test: $(TEST_BINARY) $(TEST_ADDRESS) $(TEST_BASE64) $(TEST_BUFFER) $(TEST_CHARSET) $(TEST_CONFIG) $(TEST_DATE) $(TEST_ENVLIST) $(TEST_FILE) $(TEST_GROUP) $(TEST_HASH) $(TEST_HISTORY) $(TEST_IDNA) $(TEST_LIST) $(TEST_LOGGING) $(TEST_MAPPING) $(TEST_MBYTE) $(TEST_MD5) $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING)
+all-test: $(TEST_BINARY) $(TEST_ADDRESS) $(TEST_BASE64) $(TEST_BUFFER) $(TEST_CHARSET) $(TEST_CONFIG) $(TEST_DATE) $(TEST_ENVLIST) $(TEST_FILE) $(TEST_GROUP) $(TEST_HASH) $(TEST_HISTORY) $(TEST_IDNA) $(TEST_LIST) $(TEST_LOGGING) $(TEST_MAPPING) $(TEST_MBYTE) $(TEST_MD5) $(TEST_MEMORY) $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING)
 
 clean-test:
        $(RM) $(TEST_BINARY) $(TEST_OBJS) $(TEST_OBJS:.o=.Po) \
@@ -541,6 +556,7 @@ clean-test:
              $(TEST_MAPPING) $(MAPPING_OBJS) $(MAPPING_OBJS:.o=.Po) \
              $(TEST_MBYTE) $(MBYTE_OBJS) $(MBYTE_OBJS:.o=.Po) \
              $(TEST_MD5) $(MD5_OBJS) $(MD5_OBJS:.o=.Po) \
+             $(TEST_MEMORY) $(MEMORY_OBJS) $(MEMORY_OBJS:.o=.Po) \
              $(TEST_PATH) $(PATH_OBJS) $(PATH_OBJS:.o=.Po) \
              $(TEST_PATTERN) $(PATTERN_OBJS) $(PATTERN_OBJS:.o=.Po) \
              $(TEST_STRING) $(STRING_OBJS) $(STRING_OBJS:.o=.Po)
@@ -602,6 +618,9 @@ MBYTE_DEPFILES = $(MBYTE_OBJS:.o=.Po)
 MD5_DEPFILES = $(MD5_OBJS:.o=.Po)
 -include $(MD5_DEPFILES)
 
+MEMORY_DEPFILES = $(MEMORY_OBJS:.o=.Po)
+-include $(MEMORY_DEPFILES)
+
 PATH_DEPFILES = $(PATH_OBJS:.o=.Po)
 -include $(PATH_DEPFILES)
 
diff --git a/test/memory/main.c b/test/memory/main.c
new file mode 100644 (file)
index 0000000..6d9d81c
--- /dev/null
@@ -0,0 +1,46 @@
+/**
+ * @file
+ * Test code for memory Operations
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "acutest.h"
+
+/******************************************************************************
+ * Add your test cases to this list.
+ *****************************************************************************/
+#define NEOMUTT_TEST_LIST                                                      \
+  NEOMUTT_TEST_ITEM(test_mutt_mem_calloc)                                      \
+  NEOMUTT_TEST_ITEM(test_mutt_mem_free)                                        \
+  NEOMUTT_TEST_ITEM(test_mutt_mem_malloc)                                      \
+  NEOMUTT_TEST_ITEM(test_mutt_mem_realloc)
+
+/******************************************************************************
+ * You probably don't need to touch what follows.
+ *****************************************************************************/
+#define NEOMUTT_TEST_ITEM(x) void x(void);
+NEOMUTT_TEST_LIST
+#undef NEOMUTT_TEST_ITEM
+
+TEST_LIST = {
+#define NEOMUTT_TEST_ITEM(x) { #x, x },
+  NEOMUTT_TEST_LIST
+#undef NEOMUTT_TEST_ITEM
+  { 0 }
+};
diff --git a/test/memory/mutt_mem_calloc.c b/test/memory/mutt_mem_calloc.c
new file mode 100644 (file)
index 0000000..16da646
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * @file
+ * Test code for mutt_mem_calloc()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+
+void test_mutt_mem_calloc(void)
+{
+  // void *mutt_mem_calloc(size_t nmemb, size_t size);
+}
diff --git a/test/memory/mutt_mem_free.c b/test/memory/mutt_mem_free.c
new file mode 100644 (file)
index 0000000..f620826
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * @file
+ * Test code for mutt_mem_free()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+
+void test_mutt_mem_free(void)
+{
+  // void mutt_mem_free(void *ptr);
+}
diff --git a/test/memory/mutt_mem_malloc.c b/test/memory/mutt_mem_malloc.c
new file mode 100644 (file)
index 0000000..5252f8e
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * @file
+ * Test code for mutt_mem_malloc()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+
+void test_mutt_mem_malloc(void)
+{
+  // void *mutt_mem_malloc(size_t size);
+}
diff --git a/test/memory/mutt_mem_realloc.c b/test/memory/mutt_mem_realloc.c
new file mode 100644 (file)
index 0000000..1e18d32
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * @file
+ * Test code for mutt_mem_realloc()
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TEST_NO_MAIN
+#include "acutest.h"
+#include "config.h"
+#include "mutt/mutt.h"
+
+void test_mutt_mem_realloc(void)
+{
+  // void mutt_mem_realloc(void *ptr, size_t size);
+}