diff options
Diffstat (limited to 'test/uploader_test.cc')
| -rw-r--r-- | test/uploader_test.cc | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/test/uploader_test.cc b/test/uploader_test.cc new file mode 100644 index 000000000..c583de667 --- /dev/null +++ b/test/uploader_test.cc @@ -0,0 +1,83 @@ +/* + Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + + 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "lib/uploader.h" +#include <boost/bind.hpp> +#include <boost/test/unit_test.hpp> + +using std::vector; +using std::make_pair; +using std::pair; +using std::string; +using boost::shared_ptr; +using boost::bind; + +static void +set_status (string) +{ + +} + +static void +set_progress (float) +{ + +} + +class TestUploader : public Uploader +{ +public: + TestUploader () + : Uploader (bind (&set_status, _1), bind (&set_progress, _1)) + { + _directories.push_back ("uploader"); + _directories.push_back ("uploader/a"); + _directories.push_back ("uploader/c"); + _directories.push_back ("uploader/b"); + _directories.push_back ("uploader/b/e"); + _next_directory = _directories.begin (); + + _files.push_back (make_pair ("test/data/uploader/a/d", "uploader/a/d")); + _files.push_back (make_pair ("test/data/uploader/b/e/f", "uploader/b/e/f")); + _next_file = _files.begin (); + } + +protected: + void create_directory (boost::filesystem::path directory) { + BOOST_CHECK (directory == *_next_directory); + ++_next_directory; + } + + void upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t &, boost::uintmax_t) { + BOOST_CHECK (make_pair (from, to) == *_next_file); + ++_next_file; + } + +private: + vector<boost::filesystem::path> _directories; + vector<boost::filesystem::path>::iterator _next_directory; + vector<std::pair<boost::filesystem::path, boost::filesystem::path> > _files; + vector<std::pair<boost::filesystem::path, boost::filesystem::path> >::iterator _next_file; +}; + +BOOST_AUTO_TEST_CASE (uploader_test) +{ + TestUploader uploader; + uploader.upload ("test/data/uploader"); +} |
