From: Richard Russon Date: Thu, 18 Apr 2019 22:26:39 +0000 (+0100) Subject: test: templates for path functions X-Git-Tag: 2019-10-25~247^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=904baba5145c5f30df07ed2d8d51b97399c6be9e;p=neomutt test: templates for path functions --- diff --git a/.gitignore b/.gitignore index 330609b16..bd974c33a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ neomutt pgpewrap test/config-test test/neomutt-test +test/path-test test/pattern-test test/string-test diff --git a/test/Makefile.autosetup b/test/Makefile.autosetup index a77761d00..569970a4c 100644 --- a/test/Makefile.autosetup +++ b/test/Makefile.autosetup @@ -17,6 +17,23 @@ CONFIG_OBJS = test/config/main.o test/config/account.o \ test/config/regex.o test/config/set.o test/config/sort.o \ test/config/string.o test/config/synonym.o +PATH_OBJS = test/path/main.o \ + test/path/mutt_path_abbr_folder.o \ + test/path/mutt_path_basename.o \ + test/path/mutt_path_canon.o \ + test/path/mutt_path_concat.o \ + test/path/mutt_path_concatn.o \ + test/path/mutt_path_dirname.o \ + test/path/mutt_path_escape.o \ + test/path/mutt_path_getcwd.o \ + test/path/mutt_path_parent.o \ + test/path/mutt_path_pretty.o \ + test/path/mutt_path_realpath.o \ + test/path/mutt_path_tidy.o \ + test/path/mutt_path_tidy_dotdot.o \ + test/path/mutt_path_tidy_slash.o \ + test/path/mutt_path_to_absolute.o + PATTERN_OBJS = test/pattern/main.o \ test/pattern/comp.o \ test/pattern/dummy.o \ @@ -77,14 +94,17 @@ TEST_BINARY = test/neomutt-test$(EXEEXT) TEST_CONFIG = test/config-test$(EXEEXT) +TEST_PATH = test/path-test$(EXEEXT) + TEST_PATTERN = test/pattern-test$(EXEEXT) TEST_STRING = test/string-test$(EXEEXT) .PHONY: test -test: $(TEST_BINARY) $(TEST_CONFIG) $(TEST_PATTERN) $(TEST_STRING) +test: $(TEST_BINARY) $(TEST_CONFIG) $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING) $(TEST_BINARY) $(TEST_CONFIG) + $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING) @@ -94,6 +114,9 @@ $(TEST_BINARY): $(TEST_OBJS) $(MUTTLIBS) $(TEST_CONFIG): $(PWD)/test/config $(CONFIG_OBJS) $(MUTTLIBS) $(CC) -o $@ $(CONFIG_OBJS) $(MUTTLIBS) $(LDFLAGS) $(LIBS) +$(TEST_PATH): $(PWD)/test/path $(PATH_OBJS) $(MUTTLIBS) + $(CC) -o $@ $(PATH_OBJS) $(MUTTLIBS) $(LDFLAGS) $(LIBS) + $(TEST_PATTERN): $(PWD)/test/pattern $(PATTERN_OBJS) $(MUTTLIBS) $(CC) -o $@ $(PATTERN_OBJS) $(MUTTLIBS) $(LDFLAGS) $(LIBS) @@ -103,17 +126,21 @@ $(TEST_STRING): $(PWD)/test/string $(STRING_OBJS) $(MUTTLIBS) $(PWD)/test/config: $(MKDIR_P) $(PWD)/test/config +$(PWD)/test/path: + $(MKDIR_P) $(PWD)/test/path + $(PWD)/test/pattern: $(MKDIR_P) $(PWD)/test/pattern $(PWD)/test/string: $(MKDIR_P) $(PWD)/test/string -all-test: $(TEST_BINARY) $(TEST_CONFIG) $(TEST_PATTERN) $(TEST_STRING) +all-test: $(TEST_BINARY) $(TEST_CONFIG) $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING) clean-test: $(RM) $(TEST_BINARY) $(TEST_OBJS) $(TEST_OBJS:.o=.Po) \ $(TEST_CONFIG) $(CONFIG_OBJS) $(CONFIG_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) @@ -126,6 +153,9 @@ TEST_DEPFILES = $(TEST_OBJS:.o=.Po) CONFIG_DEPFILES = $(CONFIG_OBJS:.o=.Po) -include $(CONFIG_DEPFILES) +PATH_DEPFILES = $(PATH_OBJS:.o=.Po) +-include $(PATH_DEPFILES) + PATTERN_DEPFILES = $(PATTERN_OBJS:.o=.Po) -include $(PATTERN_DEPFILES) diff --git a/test/path/main.c b/test/path/main.c new file mode 100644 index 000000000..13e6b778c --- /dev/null +++ b/test/path/main.c @@ -0,0 +1,57 @@ +/** + * @file + * Test code for Path Operations + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#include "acutest.h" + +/****************************************************************************** + * Add your test cases to this list. + *****************************************************************************/ +#define NEOMUTT_TEST_LIST \ + NEOMUTT_TEST_ITEM(test_mutt_path_abbr_folder) \ + NEOMUTT_TEST_ITEM(test_mutt_path_basename) \ + NEOMUTT_TEST_ITEM(test_mutt_path_canon) \ + NEOMUTT_TEST_ITEM(test_mutt_path_concat) \ + NEOMUTT_TEST_ITEM(test_mutt_path_concatn) \ + NEOMUTT_TEST_ITEM(test_mutt_path_dirname) \ + NEOMUTT_TEST_ITEM(test_mutt_path_escape) \ + NEOMUTT_TEST_ITEM(test_mutt_path_getcwd) \ + NEOMUTT_TEST_ITEM(test_mutt_path_parent) \ + NEOMUTT_TEST_ITEM(test_mutt_path_pretty) \ + NEOMUTT_TEST_ITEM(test_mutt_path_realpath) \ + NEOMUTT_TEST_ITEM(test_mutt_path_tidy) \ + NEOMUTT_TEST_ITEM(test_mutt_path_tidy_dotdot) \ + NEOMUTT_TEST_ITEM(test_mutt_path_tidy_slash) \ + NEOMUTT_TEST_ITEM(test_mutt_path_to_absolute) + +/****************************************************************************** + * 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/path/mutt_path_abbr_folder.c b/test/path/mutt_path_abbr_folder.c new file mode 100644 index 000000000..758af4dfd --- /dev/null +++ b/test/path/mutt_path_abbr_folder.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_abbr_folder() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_abbr_folder(void) +{ + // bool mutt_path_abbr_folder(char *buf, size_t buflen, const char *folder); +} diff --git a/test/path/mutt_path_basename.c b/test/path/mutt_path_basename.c new file mode 100644 index 000000000..f8886cb40 --- /dev/null +++ b/test/path/mutt_path_basename.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_basename() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_basename(void) +{ + // const char *mutt_path_basename(const char *f); +} diff --git a/test/path/mutt_path_canon.c b/test/path/mutt_path_canon.c new file mode 100644 index 000000000..89f2548fb --- /dev/null +++ b/test/path/mutt_path_canon.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_canon() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_canon(void) +{ + // bool mutt_path_canon(char *buf, size_t buflen, const char *homedir); +} diff --git a/test/path/mutt_path_concat.c b/test/path/mutt_path_concat.c new file mode 100644 index 000000000..e5a74e6f2 --- /dev/null +++ b/test/path/mutt_path_concat.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_concat() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_concat(void) +{ + // char *mutt_path_concat(char *d, const char *dir, const char *fname, size_t l); +} diff --git a/test/path/mutt_path_concatn.c b/test/path/mutt_path_concatn.c new file mode 100644 index 000000000..e866a2fe6 --- /dev/null +++ b/test/path/mutt_path_concatn.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_concatn() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +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); +} diff --git a/test/path/mutt_path_dirname.c b/test/path/mutt_path_dirname.c new file mode 100644 index 000000000..0fae79e42 --- /dev/null +++ b/test/path/mutt_path_dirname.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_dirname() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_dirname(void) +{ + // char *mutt_path_dirname(const char *path); +} diff --git a/test/path/mutt_path_escape.c b/test/path/mutt_path_escape.c new file mode 100644 index 000000000..99874d49e --- /dev/null +++ b/test/path/mutt_path_escape.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_escape() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_escape(void) +{ + // char *mutt_path_escape(const char *src); +} diff --git a/test/path/mutt_path_getcwd.c b/test/path/mutt_path_getcwd.c new file mode 100644 index 000000000..3e9ac5d12 --- /dev/null +++ b/test/path/mutt_path_getcwd.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_getcwd() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_getcwd(void) +{ + // void mutt_path_getcwd(struct Buffer *cwd); +} diff --git a/test/path/mutt_path_parent.c b/test/path/mutt_path_parent.c new file mode 100644 index 000000000..0a0468fa5 --- /dev/null +++ b/test/path/mutt_path_parent.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_parent() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_parent(void) +{ + // bool mutt_path_parent(char *buf, size_t buflen); +} diff --git a/test/path/mutt_path_pretty.c b/test/path/mutt_path_pretty.c new file mode 100644 index 000000000..8b2f817a4 --- /dev/null +++ b/test/path/mutt_path_pretty.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_pretty() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_pretty(void) +{ + // bool mutt_path_pretty(char *buf, size_t buflen, const char *homedir); +} diff --git a/test/path/mutt_path_realpath.c b/test/path/mutt_path_realpath.c new file mode 100644 index 000000000..165d8c363 --- /dev/null +++ b/test/path/mutt_path_realpath.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_realpath() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_realpath(void) +{ + // size_t mutt_path_realpath(char *buf); +} diff --git a/test/path/mutt_path_tidy.c b/test/path/mutt_path_tidy.c new file mode 100644 index 000000000..562a936a4 --- /dev/null +++ b/test/path/mutt_path_tidy.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_tidy() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_tidy(void) +{ + // bool mutt_path_tidy(char *buf); +} diff --git a/test/path/mutt_path_tidy_dotdot.c b/test/path/mutt_path_tidy_dotdot.c new file mode 100644 index 000000000..de0822fb1 --- /dev/null +++ b/test/path/mutt_path_tidy_dotdot.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_tidy_dotdot() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_tidy_dotdot(void) +{ + // bool mutt_path_tidy_dotdot(char *buf); +} diff --git a/test/path/mutt_path_tidy_slash.c b/test/path/mutt_path_tidy_slash.c new file mode 100644 index 000000000..3ace0e84c --- /dev/null +++ b/test/path/mutt_path_tidy_slash.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_tidy_slash() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_tidy_slash(void) +{ + // bool mutt_path_tidy_slash(char *buf); +} diff --git a/test/path/mutt_path_to_absolute.c b/test/path/mutt_path_to_absolute.c new file mode 100644 index 000000000..06d38a9a3 --- /dev/null +++ b/test/path/mutt_path_to_absolute.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_path_to_absolute() + * + * @authors + * Copyright (C) 2019 Richard Russon + * + * @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 . + */ + +#define TEST_NO_MAIN +#include "acutest.h" +#include "config.h" +#include "mutt/mutt.h" + +void test_mutt_path_to_absolute(void) +{ + // int mutt_path_to_absolute(char *path, const char *reference); +}