/* Copyright 2015, Michele Santullo
 * This file is part of DoorKeeper.
 *
 * DoorKeeper 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 3 of the License, or
 * (at your option) any later version.
 *
 * DoorKeeper 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 DoorKeeper.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtest/gtest.h>
#include "doorkeeper/components/tileiterator.hpp"
#include "doorkeeper/components/pixelconv.hpp"
#include <vector>
#include <boost/iterator/counting_iterator.hpp>
#include <limits>

TEST(tileiterator, increment) {
	typedef dk::TileIterator<int, 7> tileit7;
	typedef dk::Vector<7> coords7;

	using boost::counting_iterator;

	std::vector<int> data(counting_iterator<int>(0), counting_iterator<int>(100000));
	dk::PixelConvSquare<7> pixconv(coords7(16));

	{
		const coords7 max_coords(99, 999, 2, 2, 2, 2, 2);
		tileit7 it(&data, pixconv, max_coords);

		for (std::size_t z = 0; z < data.size() - 1; ++z) {
			EXPECT_EQ(data[z], it->data());
			++it;
		}

		EXPECT_EQ(data[data.size() - 1], it->data());
		EXPECT_EQ(coords7(99, 999, 0, 0, 0, 0, 0), it->block_position());
	}
}
