<commit_before>#include "test_grid_loop.h"
#include "test.h"

#include <cassert>

#include "../common/grid_loop.h"

namespace penciloid
{
namespace test
{
void RunAllGridLoopTest()
{
	GridLoopBasicAccessors();
	GridLoopDecideEdgeBasic();
	GridLoopInspectVertex();
	GridLoopCopy();
	GridLoopClosedLoop();
}
void GridLoopBasicAccessors()
{
	PlainGridLoop field(3, 3);

	assert(field.height() == 3);
	assert(field.width() == 3);
	assert(field.IsInconsistent() == false);
	assert(field.IsFullySolved() == false);
	assert(field.IsInAbnormalCondition() == false);

	field.SetInconsistent();
	assert(field.IsInconsistent() == true);
}
void GridLoopDecideEdgeBasic()
{
	PlainGridLoop field(3, 3);

	field.DecideEdge(Position(2, 1), PlainGridLoop::EDGE_LINE);
	field.DecideEdge(Position(4, 3), PlainGridLoop::EDGE_BLANK);

	assert(field.GetEdge(Position(2, 1)) == PlainGridLoop::EDGE_LINE);
	assert(field.GetEdge(Position(4, 3)) == PlainGridLoop::EDGE_BLANK);
}
void GridLoopInspectVertex()
{
	{
		// two lines from a vertex: another edges will be blank
		PlainGridLoop field(3, 3);

		field.DecideEdge(Position(2, 1), PlainGridLoop::EDGE_LINE);
		field.DecideEdge(Position(3, 2), PlainGridLoop::EDGE_LINE);

		assert(field.GetEdge(Position(1, 2)) == PlainGridLoop::EDGE_BLANK);
		assert(field.GetEdge(Position(2, 3)) == PlainGridLoop::EDGE_BLANK);
	}
	{
		// one line and two blanks from a vertex: the another edge will be a line
		PlainGridLoop field(3, 3);

		field.DecideEdge(Position(3, 2), PlainGridLoop::EDGE_BLANK);
		field.DecideEdge(Position(2, 1), PlainGridLoop::EDGE_LINE);
		field.DecideEdge(Position(1, 2), PlainGridLoop::EDGE_BLANK);

		assert(field.GetEdge(Position(2, 3)) == PlainGridLoop::EDGE_LINE);
	}
	{
		// 3 blanks from a vertex: the another edge will also be blank
		PlainGridLoop field(3, 3);

		field.DecideEdge(Position(3, 2), PlainGridLoop::EDGE_BLANK);
		field.DecideEdge(Position(2, 1), PlainGridLoop::EDGE_BLANK);
		field.DecideEdge(Position(1, 2), PlainGridLoop::EDGE_BLANK);

		assert(field.GetEdge(Position(2, 3)) == PlainGridLoop::EDGE_BLANK);
	}
	{
		// around corner
		PlainGridLoop field(3, 3);

		field.DecideEdge(Position(0, 1), PlainGridLoop::EDGE_BLANK);
		field.DecideEdge(Position(6, 1), PlainGridLoop::EDGE_LINE);

		assert(field.GetEdge(Position(1, 0)) == PlainGridLoop::EDGE_BLANK);
		assert(field.GetEdge(Position(5, 0)) == PlainGridLoop::EDGE_LINE);
	}
	{
		// small loop avoidance
		PlainGridLoop field(3, 3);

		field.DecideEdge(Position(3, 6), PlainGridLoop::EDGE_LINE);
		field.DecideEdge(Position(0, 3), PlainGridLoop::EDGE_BLANK);
		field.DecideEdge(Position(1, 0), PlainGridLoop::EDGE_LINE);

		assert(field.GetEdge(Position(2, 1)) == PlainGridLoop::EDGE_BLANK);
	}
}
void GridLoopCopy()
{
	PlainGridLoop field(3, 3);

	field.DecideEdge(Position(2, 3), PlainGridLoop::EDGE_LINE);

	PlainGridLoop field2(field);

	assert(field2.GetEdge(Position(2, 3)) == PlainGridLoop::EDGE_LINE);
}
void GridLoopClosedLoop()
{
	PlainGridLoop field(3, 3);
	
	field.DecideEdge(Position(0, 1), PlainGridLoop::EDGE_LINE);
	field.DecideEdge(Position(1, 0), PlainGridLoop::EDGE_LINE);
	field.DecideEdge(Position(2, 1), PlainGridLoop::EDGE_LINE);
	field.DecideEdge(Position(1, 2), PlainGridLoop::EDGE_LINE);

	assert(field.IsFullySolved() == true);
}
}
}<commit_msg>GridLoop: modify a test to verify HasFullySolved<commit_after>#include "test_grid_loop.h"
#include "test.h"

#include <cassert>

#include "../common/grid_loop.h"

namespace penciloid
{
namespace test
{
void RunAllGridLoopTest()
{
	GridLoopBasicAccessors();
	GridLoopDecideEdgeBasic();
	GridLoopInspectVertex();
	GridLoopCopy();
	GridLoopClosedLoop();
}
void GridLoopBasicAccessors()
{
	PlainGridLoop field(3, 3);

	assert(field.height() == 3);
	assert(field.width() == 3);
	assert(field.IsInconsistent() == false);
	assert(field.IsFullySolved() == false);
	assert(field.IsInAbnormalCondition() == false);

	field.SetInconsistent();
	assert(field.IsInconsistent() == true);
}
void GridLoopDecideEdgeBasic()
{
	PlainGridLoop field(3, 3);

	field.DecideEdge(Position(2, 1), PlainGridLoop::EDGE_LINE);
	field.DecideEdge(Position(4, 3), PlainGridLoop::EDGE_BLANK);

	assert(field.GetEdge(Position(2, 1)) == PlainGridLoop::EDGE_LINE);
	assert(field.GetEdge(Position(4, 3)) == PlainGridLoop::EDGE_BLANK);
}
void GridLoopInspectVertex()
{
	{
		// two lines from a vertex: another edges will be blank
		PlainGridLoop field(3, 3);

		field.DecideEdge(Position(2, 1), PlainGridLoop::EDGE_LINE);
		field.DecideEdge(Position(3, 2), PlainGridLoop::EDGE_LINE);

		assert(field.GetEdge(Position(1, 2)) == PlainGridLoop::EDGE_BLANK);
		assert(field.GetEdge(Position(2, 3)) == PlainGridLoop::EDGE_BLANK);
	}
	{
		// one line and two blanks from a vertex: the another edge will be a line
		PlainGridLoop field(3, 3);

		field.DecideEdge(Position(3, 2), PlainGridLoop::EDGE_BLANK);
		field.DecideEdge(Position(2, 1), PlainGridLoop::EDGE_LINE);
		field.DecideEdge(Position(1, 2), PlainGridLoop::EDGE_BLANK);

		assert(field.GetEdge(Position(2, 3)) == PlainGridLoop::EDGE_LINE);
	}
	{
		// 3 blanks from a vertex: the another edge will also be blank
		PlainGridLoop field(3, 3);

		field.DecideEdge(Position(3, 2), PlainGridLoop::EDGE_BLANK);
		field.DecideEdge(Position(2, 1), PlainGridLoop::EDGE_BLANK);
		field.DecideEdge(Position(1, 2), PlainGridLoop::EDGE_BLANK);

		assert(field.GetEdge(Position(2, 3)) == PlainGridLoop::EDGE_BLANK);
	}
	{
		// around corner
		PlainGridLoop field(3, 3);

		field.DecideEdge(Position(0, 1), PlainGridLoop::EDGE_BLANK);
		field.DecideEdge(Position(6, 1), PlainGridLoop::EDGE_LINE);

		assert(field.GetEdge(Position(1, 0)) == PlainGridLoop::EDGE_BLANK);
		assert(field.GetEdge(Position(5, 0)) == PlainGridLoop::EDGE_LINE);
	}
	{
		// small loop avoidance
		PlainGridLoop field(3, 3);

		field.DecideEdge(Position(3, 6), PlainGridLoop::EDGE_LINE);
		field.DecideEdge(Position(0, 3), PlainGridLoop::EDGE_BLANK);
		field.DecideEdge(Position(1, 0), PlainGridLoop::EDGE_LINE);

		assert(field.GetEdge(Position(2, 1)) == PlainGridLoop::EDGE_BLANK);
	}
}
void GridLoopCopy()
{
	PlainGridLoop field(3, 3);

	field.DecideEdge(Position(2, 3), PlainGridLoop::EDGE_LINE);

	PlainGridLoop field2(field);

	assert(field2.GetEdge(Position(2, 3)) == PlainGridLoop::EDGE_LINE);
}
void GridLoopClosedLoop()
{
	PlainGridLoop field(3, 3);
	
	field.DecideEdge(Position(0, 1), PlainGridLoop::EDGE_LINE);
	field.DecideEdge(Position(1, 0), PlainGridLoop::EDGE_LINE);
	field.DecideEdge(Position(2, 1), PlainGridLoop::EDGE_LINE);
	field.DecideEdge(Position(1, 2), PlainGridLoop::EDGE_LINE);

	assert(field.IsFullySolved() == true);
	assert(field.GetEdge(Position(0, 5)) == PlainGridLoop::EDGE_BLANK);
}
}
}
{'fraction_non_alphanumeric': 0.1567454382291355, 'fraction_numerical': 0.025127131319174396, 'mean_word_length': 6.695051783659379, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2616632', 'n_tokens_mistral': 2717, 'n_tokens_neox': 2455, 'n_words': 419}