From 47f8f13eb404a0664fa9ee7f3933643d4033d8d8 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sun, 28 Apr 2019 12:37:15 +0100 Subject: [PATCH] test: templates for base64 functions --- .gitignore | 1 + test/Makefile.autosetup | 23 ++++++++++++-- test/base64/main.c | 46 ++++++++++++++++++++++++++++ test/base64/mutt_b64_buffer_decode.c | 31 +++++++++++++++++++ test/base64/mutt_b64_buffer_encode.c | 31 +++++++++++++++++++ test/base64/mutt_b64_decode.c | 31 +++++++++++++++++++ test/base64/mutt_b64_encode.c | 31 +++++++++++++++++++ 7 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 test/base64/main.c create mode 100644 test/base64/mutt_b64_buffer_decode.c create mode 100644 test/base64/mutt_b64_buffer_encode.c create mode 100644 test/base64/mutt_b64_decode.c create mode 100644 test/base64/mutt_b64_encode.c diff --git a/.gitignore b/.gitignore index a1e68392b..4c81b89e1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ doc/makedoc neomutt pgpewrap test/address-test +test/base64-test test/config-test test/group-test test/idna-test diff --git a/test/Makefile.autosetup b/test/Makefile.autosetup index e2cd24958..39b421f89 100644 --- a/test/Makefile.autosetup +++ b/test/Makefile.autosetup @@ -35,6 +35,12 @@ ADDRESS_OBJS = test/address/main.o \ test/address/mutt_addr_write.o \ test/address/mutt_addr_write_single.o +BASE64_OBJS = test/base64/main.o \ + test/base64/mutt_b64_buffer_decode.o \ + test/base64/mutt_b64_buffer_encode.o \ + test/base64/mutt_b64_decode.o \ + test/base64/mutt_b64_encode.o + CONFIG_OBJS = test/config/main.o test/config/account.o \ test/config/address.o test/config/bool.o \ test/config/command.o test/config/common.o test/config/dump.o \ @@ -140,6 +146,8 @@ TEST_BINARY = test/neomutt-test$(EXEEXT) TEST_ADDRESS = test/address-test$(EXEEXT) +TEST_BASE64 = test/base64-test$(EXEEXT) + TEST_CONFIG = test/config-test$(EXEEXT) TEST_GROUP = test/group-test$(EXEEXT) @@ -153,9 +161,10 @@ TEST_PATTERN = test/pattern-test$(EXEEXT) TEST_STRING = test/string-test$(EXEEXT) .PHONY: test -test: $(TEST_BINARY) $(TEST_ADDRESS) $(TEST_CONFIG) $(TEST_GROUP) $(TEST_IDNA) $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING) +test: $(TEST_BINARY) $(TEST_ADDRESS) $(TEST_BASE64) $(TEST_CONFIG) $(TEST_GROUP) $(TEST_IDNA) $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING) $(TEST_BINARY) $(TEST_ADDRESS) + $(TEST_BASE64) $(TEST_CONFIG) $(TEST_GROUP) $(TEST_IDNA) @@ -169,6 +178,9 @@ $(TEST_BINARY): $(TEST_OBJS) $(MUTTLIBS) $(TEST_ADDRESS): $(PWD)/test/address $(ADDRESS_OBJS) $(MUTTLIBS) $(CC) -o $@ $(ADDRESS_OBJS) $(MUTTLIBS) $(LDFLAGS) $(LIBS) +$(TEST_BASE64): $(PWD)/test/base64 $(BASE64_OBJS) $(MUTTLIBS) + $(CC) -o $@ $(BASE64_OBJS) $(MUTTLIBS) $(LDFLAGS) $(LIBS) + $(TEST_CONFIG): $(PWD)/test/config $(CONFIG_OBJS) $(MUTTLIBS) $(CC) -o $@ $(CONFIG_OBJS) $(MUTTLIBS) $(LDFLAGS) $(LIBS) @@ -190,6 +202,9 @@ $(TEST_STRING): $(PWD)/test/string $(STRING_OBJS) $(MUTTLIBS) $(PWD)/test/address: $(MKDIR_P) $(PWD)/test/address +$(PWD)/test/base64: + $(MKDIR_P) $(PWD)/test/base64 + $(PWD)/test/config: $(MKDIR_P) $(PWD)/test/config @@ -208,11 +223,12 @@ $(PWD)/test/pattern: $(PWD)/test/string: $(MKDIR_P) $(PWD)/test/string -all-test: $(TEST_BINARY) $(TEST_ADDRESS) $(TEST_CONFIG) $(TEST_GROUP) $(TEST_IDNA) $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING) +all-test: $(TEST_BINARY) $(TEST_ADDRESS) $(TEST_BASE64) $(TEST_CONFIG) $(TEST_GROUP) $(TEST_IDNA) $(TEST_PATH) $(TEST_PATTERN) $(TEST_STRING) clean-test: $(RM) $(TEST_BINARY) $(TEST_OBJS) $(TEST_OBJS:.o=.Po) \ $(TEST_ADDRESS) $(ADDRESS_OBJS) $(ADDRESS_OBJS:.o=.Po) \ + $(TEST_BASE64) $(BASE64_OBJS) $(BASE64_OBJS:.o=.Po) \ $(TEST_CONFIG) $(CONFIG_OBJS) $(CONFIG_OBJS:.o=.Po) \ $(TEST_GROUP) $(GROUP_OBJS) $(GROUP_OBJS:.o=.Po) \ $(TEST_IDNA) $(IDNA_OBJS) $(IDNA_OBJS:.o=.Po) \ @@ -229,6 +245,9 @@ TEST_DEPFILES = $(TEST_OBJS:.o=.Po) ADDRESS_DEPFILES = $(ADDRESS_OBJS:.o=.Po) -include $(ADDRESS_DEPFILES) +BASE64_DEPFILES = $(BASE64_OBJS:.o=.Po) +-include $(BASE64_DEPFILES) + CONFIG_DEPFILES = $(CONFIG_OBJS:.o=.Po) -include $(CONFIG_DEPFILES) diff --git a/test/base64/main.c b/test/base64/main.c new file mode 100644 index 000000000..b96b17569 --- /dev/null +++ b/test/base64/main.c @@ -0,0 +1,46 @@ +/** + * @file + * Test code for base64 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_b64_buffer_decode) \ + NEOMUTT_TEST_ITEM(test_mutt_b64_buffer_encode) \ + NEOMUTT_TEST_ITEM(test_mutt_b64_decode) \ + NEOMUTT_TEST_ITEM(test_mutt_b64_encode) + +/****************************************************************************** + * 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/base64/mutt_b64_buffer_decode.c b/test/base64/mutt_b64_buffer_decode.c new file mode 100644 index 000000000..24be5b279 --- /dev/null +++ b/test/base64/mutt_b64_buffer_decode.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_b64_buffer_decode() + * + * @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_b64_buffer_decode(void) +{ + // int mutt_b64_buffer_decode(struct Buffer *buf, const char *in); +} diff --git a/test/base64/mutt_b64_buffer_encode.c b/test/base64/mutt_b64_buffer_encode.c new file mode 100644 index 000000000..ac1032e7a --- /dev/null +++ b/test/base64/mutt_b64_buffer_encode.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_b64_buffer_encode() + * + * @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_b64_buffer_encode(void) +{ + // size_t mutt_b64_buffer_encode(struct Buffer *buf, const char *in, size_t len); +} diff --git a/test/base64/mutt_b64_decode.c b/test/base64/mutt_b64_decode.c new file mode 100644 index 000000000..7693181b5 --- /dev/null +++ b/test/base64/mutt_b64_decode.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_b64_decode() + * + * @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_b64_decode(void) +{ + // int mutt_b64_decode(const char *in, char *out, size_t olen); +} diff --git a/test/base64/mutt_b64_encode.c b/test/base64/mutt_b64_encode.c new file mode 100644 index 000000000..6ae489831 --- /dev/null +++ b/test/base64/mutt_b64_encode.c @@ -0,0 +1,31 @@ +/** + * @file + * Test code for mutt_b64_encode() + * + * @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_b64_encode(void) +{ + // size_t mutt_b64_encode(const char *in, size_t inlen, char *out, size_t outlen); +} -- 2.40.0