<commit_before>
#include <gtest/gtest.h>

#include <zinc/zincconfigure.h>
#include <zinc/status.h>
#include <zinc/core.h>
#include <zinc/graphic.h>
#include <zinc/graphicsfilter.h>

#include "zinctestsetup.hpp"
#include "zinctestsetupcpp.hpp"
#include "zinc/graphicsfilter.hpp"

TEST(Cmiss_graphics_filter_module_api, valid_args)
{
	ZincTestSetup zinc;

	Cmiss_graphics_filter_module_id gfm = Cmiss_graphics_module_get_filter_module(zinc.gm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter_module *>(0), gfm);

	int result = Cmiss_graphics_filter_module_begin_change(gfm);
	EXPECT_EQ(CMISS_OK, result);

	Cmiss_graphics_filter_id filter = Cmiss_graphics_filter_module_create_filter_visibility_flags(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	result = Cmiss_graphics_filter_set_name(filter, "default");
	EXPECT_EQ(CMISS_OK, result);

	result = Cmiss_graphics_filter_module_end_change(gfm);
	EXPECT_EQ(CMISS_OK, result);

	result = Cmiss_graphics_filter_module_set_default_filter(gfm, filter);
	EXPECT_EQ(CMISS_OK, result);

	result = Cmiss_graphics_filter_set_managed(filter, 1);
	EXPECT_EQ(CMISS_OK, result);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_find_filter_by_name(gfm, "default");
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_get_default_filter(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_create_filter_graphic_name(gfm, "lines");
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_create_filter_graphic_type(gfm, CMISS_GRAPHIC_POINTS);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_create_filter_region(gfm, zinc.root_region);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_create_filter_operator_and(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_create_filter_operator_or(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	Cmiss_graphics_filter_module_destroy(&gfm);
}

TEST(Cmiss_graphics_filter_module_api, valid_args_cpp)
{
	ZincTestSetupCpp zinc;

	GraphicsFilterModule gfm = zinc.gm.getFilterModule();
	EXPECT_EQ(true, gfm.isValid());

	int result = gfm.beginChange();
	EXPECT_EQ(CMISS_OK, result);

	GraphicsFilter filter = gfm.createFilterVisibilityFlags();
	EXPECT_EQ(true, filter.isValid());

	result = filter.setName("default");
	EXPECT_EQ(CMISS_OK, result);

	result = gfm.endChange();
	EXPECT_EQ(CMISS_OK, result);

	result = gfm.setDefaultFilter(filter);
	EXPECT_EQ(CMISS_OK, result);

	result = filter.setManaged(true);
	EXPECT_EQ(CMISS_OK, result);

	filter = gfm.findFilterByName("default");
	EXPECT_EQ(true, filter.isValid());

	filter = gfm.getDefaultFilter();
	EXPECT_EQ(true, filter.isValid());

	filter =  gfm.createFilterGraphicName("lines");
	EXPECT_EQ(true, filter.isValid());

	filter = gfm.createFilterGraphicType(Graphic::GRAPHIC_POINTS);
	EXPECT_EQ(true, filter.isValid());

	filter = gfm.createFilterRegion(zinc.root_region);
	EXPECT_EQ(true, filter.isValid());

	filter = gfm.createFilterOperatorAnd();
	EXPECT_EQ(true, filter.isValid());

	filter = gfm.createFilterOperatorOr();
	EXPECT_EQ(true, filter.isValid());
}

TEST(Cmiss_graphics_filter_api, valid_args)
{
	ZincTestSetup zinc;

	Cmiss_graphics_filter_module_id gfm = Cmiss_graphics_module_get_filter_module(zinc.gm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter_module *>(0), gfm);

	Cmiss_graphics_filter_id filter = Cmiss_graphics_filter_module_get_default_filter(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	int result = Cmiss_graphics_filter_set_name(filter, "visibility_flag");
	EXPECT_EQ(CMISS_OK, result);

	result = Cmiss_graphics_filter_set_managed(filter, 1);
	EXPECT_EQ(CMISS_OK, result);

	result = Cmiss_graphics_filter_set_attribute_integer(filter,
		CMISS_GRAPHICS_FILTER_ATTRIBUTE_IS_INVERSE, 0);
	EXPECT_EQ(CMISS_OK, result);

	EXPECT_EQ(1, Cmiss_graphics_filter_is_managed(filter));

	result = Cmiss_graphics_filter_get_attribute_integer(filter,
		CMISS_GRAPHICS_FILTER_ATTRIBUTE_IS_INVERSE);
	EXPECT_EQ(0, result);

	Cmiss_graphics_filter_id graphic_type_filter1 = Cmiss_graphics_filter_module_create_filter_graphic_type(gfm, CMISS_GRAPHIC_POINTS);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), graphic_type_filter1);
	Cmiss_graphics_filter_id graphic_type_filter2 = Cmiss_graphics_filter_module_create_filter_graphic_type(gfm, CMISS_GRAPHIC_LINES);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), graphic_type_filter2);
	Cmiss_graphics_filter_id domain_type_filter1 = Cmiss_graphics_filter_module_create_filter_domain_type(gfm, CMISS_FIELD_DOMAIN_NODES);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), domain_type_filter1);
	Cmiss_graphics_filter_id domain_type_filter2 = Cmiss_graphics_filter_module_create_filter_domain_type(gfm, CMISS_FIELD_DOMAIN_ELEMENTS_1D);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), domain_type_filter2);

	Cmiss_graphic_id graphic = Cmiss_rendition_create_graphic(zinc.ren, CMISS_GRAPHIC_LINES);
	EXPECT_NE(static_cast<Cmiss_graphic *>(0), graphic);

	result = Cmiss_graphics_filter_evaluate_graphic(graphic_type_filter1, graphic);
	EXPECT_EQ(0, result);
	result = Cmiss_graphics_filter_evaluate_graphic(graphic_type_filter2, graphic);
	EXPECT_EQ(1, result);
	result = Cmiss_graphics_filter_evaluate_graphic(domain_type_filter1, graphic);
	EXPECT_EQ(0, result);
	result = Cmiss_graphics_filter_evaluate_graphic(domain_type_filter2, graphic);
	EXPECT_EQ(1, result);

	result = Cmiss_graphics_filter_evaluate_graphic(filter, graphic);
	EXPECT_EQ(1, result);

	Cmiss_graphics_filter_id and_filter = Cmiss_graphics_filter_module_create_filter_operator_and(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), and_filter);

	Cmiss_graphics_filter_id or_filter = Cmiss_graphics_filter_module_create_filter_operator_or(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), or_filter);

	Cmiss_graphics_filter_operator_id and_operator = Cmiss_graphics_filter_cast_operator(and_filter);
	EXPECT_NE(static_cast<Cmiss_graphics_filter_operator *>(0), and_operator);
<commit_msg>Fix warnings on boolean/int conversions for is_managed/set_managed API unit tests. Issue 3580.<commit_after>
#include <gtest/gtest.h>

#include <zinc/zincconfigure.h>
#include <zinc/status.h>
#include <zinc/core.h>
#include <zinc/graphic.h>
#include <zinc/graphicsfilter.h>

#include "zinctestsetup.hpp"
#include "zinctestsetupcpp.hpp"
#include "zinc/graphicsfilter.hpp"

TEST(Cmiss_graphics_filter_module_api, valid_args)
{
	ZincTestSetup zinc;

	Cmiss_graphics_filter_module_id gfm = Cmiss_graphics_module_get_filter_module(zinc.gm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter_module *>(0), gfm);

	int result = Cmiss_graphics_filter_module_begin_change(gfm);
	EXPECT_EQ(CMISS_OK, result);

	Cmiss_graphics_filter_id filter = Cmiss_graphics_filter_module_create_filter_visibility_flags(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	result = Cmiss_graphics_filter_set_name(filter, "default");
	EXPECT_EQ(CMISS_OK, result);

	result = Cmiss_graphics_filter_module_end_change(gfm);
	EXPECT_EQ(CMISS_OK, result);

	result = Cmiss_graphics_filter_module_set_default_filter(gfm, filter);
	EXPECT_EQ(CMISS_OK, result);

	result = Cmiss_graphics_filter_set_managed(filter, true);
	EXPECT_EQ(CMISS_OK, result);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_find_filter_by_name(gfm, "default");
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_get_default_filter(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_create_filter_graphic_name(gfm, "lines");
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_create_filter_graphic_type(gfm, CMISS_GRAPHIC_POINTS);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_create_filter_region(gfm, zinc.root_region);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_create_filter_operator_and(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	filter = Cmiss_graphics_filter_module_create_filter_operator_or(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	Cmiss_graphics_filter_destroy(&filter);

	Cmiss_graphics_filter_module_destroy(&gfm);
}

TEST(Cmiss_graphics_filter_module_api, valid_args_cpp)
{
	ZincTestSetupCpp zinc;

	GraphicsFilterModule gfm = zinc.gm.getFilterModule();
	EXPECT_EQ(true, gfm.isValid());

	int result = gfm.beginChange();
	EXPECT_EQ(CMISS_OK, result);

	GraphicsFilter filter = gfm.createFilterVisibilityFlags();
	EXPECT_EQ(true, filter.isValid());

	result = filter.setName("default");
	EXPECT_EQ(CMISS_OK, result);

	result = gfm.endChange();
	EXPECT_EQ(CMISS_OK, result);

	result = gfm.setDefaultFilter(filter);
	EXPECT_EQ(CMISS_OK, result);

	result = filter.setManaged(true);
	EXPECT_EQ(CMISS_OK, result);

	filter = gfm.findFilterByName("default");
	EXPECT_EQ(true, filter.isValid());

	filter = gfm.getDefaultFilter();
	EXPECT_EQ(true, filter.isValid());

	filter =  gfm.createFilterGraphicName("lines");
	EXPECT_EQ(true, filter.isValid());

	filter = gfm.createFilterGraphicType(Graphic::GRAPHIC_POINTS);
	EXPECT_EQ(true, filter.isValid());

	filter = gfm.createFilterRegion(zinc.root_region);
	EXPECT_EQ(true, filter.isValid());

	filter = gfm.createFilterOperatorAnd();
	EXPECT_EQ(true, filter.isValid());

	filter = gfm.createFilterOperatorOr();
	EXPECT_EQ(true, filter.isValid());
}

TEST(Cmiss_graphics_filter_api, valid_args)
{
	ZincTestSetup zinc;

	Cmiss_graphics_filter_module_id gfm = Cmiss_graphics_module_get_filter_module(zinc.gm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter_module *>(0), gfm);

	Cmiss_graphics_filter_id filter = Cmiss_graphics_filter_module_get_default_filter(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), filter);

	int result = Cmiss_graphics_filter_set_name(filter, "visibility_flag");
	EXPECT_EQ(CMISS_OK, result);

	result = Cmiss_graphics_filter_set_managed(filter, true);
	EXPECT_EQ(CMISS_OK, result);

	result = Cmiss_graphics_filter_set_attribute_integer(filter,
		CMISS_GRAPHICS_FILTER_ATTRIBUTE_IS_INVERSE, 0);
	EXPECT_EQ(CMISS_OK, result);

	EXPECT_TRUE(Cmiss_graphics_filter_is_managed(filter));

	result = Cmiss_graphics_filter_get_attribute_integer(filter,
		CMISS_GRAPHICS_FILTER_ATTRIBUTE_IS_INVERSE);
	EXPECT_EQ(0, result);

	Cmiss_graphics_filter_id graphic_type_filter1 = Cmiss_graphics_filter_module_create_filter_graphic_type(gfm, CMISS_GRAPHIC_POINTS);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), graphic_type_filter1);
	EXPECT_FALSE(Cmiss_graphics_filter_is_managed(graphic_type_filter1));
	Cmiss_graphics_filter_id graphic_type_filter2 = Cmiss_graphics_filter_module_create_filter_graphic_type(gfm, CMISS_GRAPHIC_LINES);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), graphic_type_filter2);
	Cmiss_graphics_filter_id domain_type_filter1 = Cmiss_graphics_filter_module_create_filter_domain_type(gfm, CMISS_FIELD_DOMAIN_NODES);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), domain_type_filter1);
	Cmiss_graphics_filter_id domain_type_filter2 = Cmiss_graphics_filter_module_create_filter_domain_type(gfm, CMISS_FIELD_DOMAIN_ELEMENTS_1D);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), domain_type_filter2);

	Cmiss_graphic_id graphic = Cmiss_rendition_create_graphic(zinc.ren, CMISS_GRAPHIC_LINES);
	EXPECT_NE(static_cast<Cmiss_graphic *>(0), graphic);

	result = Cmiss_graphics_filter_evaluate_graphic(graphic_type_filter1, graphic);
	EXPECT_EQ(0, result);
	result = Cmiss_graphics_filter_evaluate_graphic(graphic_type_filter2, graphic);
	EXPECT_EQ(1, result);
	result = Cmiss_graphics_filter_evaluate_graphic(domain_type_filter1, graphic);
	EXPECT_EQ(0, result);
	result = Cmiss_graphics_filter_evaluate_graphic(domain_type_filter2, graphic);
	EXPECT_EQ(1, result);

	result = Cmiss_graphics_filter_evaluate_graphic(filter, graphic);
	EXPECT_EQ(1, result);

	Cmiss_graphics_filter_id and_filter = Cmiss_graphics_filter_module_create_filter_operator_and(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), and_filter);

	Cmiss_graphics_filter_id or_filter = Cmiss_graphics_filter_module_create_filter_operator_or(gfm);
	EXPECT_NE(static_cast<Cmiss_graphics_filter *>(0), or_filter);

	Cmiss_graphics_filter_operator_id and_operator = Cmiss_graphics_filter_cast_operator(and_filter);
	EXPECT_NE(static_cast<Cmiss_graphics_filter_operator *>(0), and_operator);

{'fraction_non_alphanumeric': 0.09984235417761429, 'fraction_numerical': 0.006455971773890849, 'mean_word_length': 10.862867319679431, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, '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': '7120509', 'n_tokens_mistral': 4895, 'n_tokens_neox': 4827, 'n_words': 587}