#include <iostream>

#include "gtest/gtest.h"

#include "fixture.h"


class OperationLogicOr : public JsonLogicTest
{
};

TEST_F(OperationLogicOr, PrimitiveTrue)
{
	const auto logic = R"(
		{
			"or": [
				false,
				true,
				false
			]
		}
	)"_json;

	const auto result = json_logic_->Apply(logic);

	EXPECT_TRUE(result.as<bool>());
}

TEST_F(OperationLogicOr, PrimitiveFalse)
{
	const auto logic = R"(
		{
			"or": [
				false,
				false,
				false
			]
		}
	)"_json;

	const auto result = json_logic_->Apply(logic);

	EXPECT_FALSE(result.as<bool>());
}

TEST_F(OperationLogicOr, NestedTrue)
{
	const auto logic = R"(
		{
			"or": [
				{
					"or": [
						true,
						false
					]
				},
				{
					"or": [
						false,
						false
					]
				},
				false
			]
		}
	)"_json;

	const auto result = json_logic_->Apply(logic);

	EXPECT_TRUE(result.as<bool>());
}

TEST_F(OperationLogicOr, NestedFalse)
{
	const auto logic = R"(
		{
			"or": [
				{
					"or": [
						false,
						false
					]
				},
				{
					"or": [
						false,
						false
					]
				},
				false
			]
		}
	)"_json;

	const auto result = json_logic_->Apply(logic);

	EXPECT_FALSE(result.as<bool>());
}
