Exemplo n.º 1
0
	bool checkSize(const Sudoku &s)
	{
		if (s.size() != 9)
			return fail("Wrong number of rows in result", "");
		for(unsigned int r = 0; r < s.size(); ++r) {
			if (s[r].size() != 9)
				return fail("Wrong number of numbers in row", r);
		}
		return true;
	}
Exemplo n.º 2
0
	bool checkInput(const Sudoku &i, const Sudoku &s)
	{
		for(unsigned int r = 0; r < i.size(); ++r)
			for(unsigned int c = 0; c < i[r].size(); ++c)
				if (i[r][c] != 0)
					if (i[r][c] != s[r][c])
						return fail("Result does not match input", r, c);
		return true;
	}
Exemplo n.º 3
0
	void test(const Sudoku &i, bool good, const Sudoku &s)
	{
		m_case++;
		std::cerr << "Case " << m_case << ": ";
		if (check(i, good, s)) {
			std::cerr << "PASSED" << std::endl;
		}
		else {
			std::cerr << "          INPUT              OUTPUT" << std::endl;
			for(unsigned int r = 0; r < std::max(i.size(), s.size()); ++r) {
				if (r<i.size()) {
					std::cerr << i[r];
				}
				else {
					std::cerr << "                    ";
				}
				std::cerr << "    ";
				if (r<s.size()) {
					std::cerr << s[r];
				}
				std::cerr << std::endl;
			}
		}
	}