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

#include <zinc/zincconfigure.h>
#include <zinc/status.h>
#include <zinc/core.h>
#include <zinc/context.h>
#include <zinc/sceneviewer.h>

#include "zinctestsetup.hpp"

TEST(Cmiss_scene_viewer_api, destroy_context_before_scene_viewer)
{
	 Cmiss_context_id context = Cmiss_context_create("test");
	 Cmiss_graphics_module_id gm = Cmiss_context_get_graphics_module(context);
	 Cmiss_scene_viewer_module_id scene_viewer_module = Cmiss_graphics_module_get_scene_viewer_module(gm);
	 Cmiss_scene_viewer_id scene_viewer = Cmiss_scene_viewer_module_create_scene_viewer(scene_viewer_module,
	  CMISS_SCENE_VIEWER_BUFFERING_ANY_MODE, CMISS_SCENE_VIEWER_STEREO_ANY_MODE);
	 Cmiss_scene_viewer_module_destroy(&scene_viewer_module);
	 Cmiss_graphics_module_destroy(&gm);
	 Cmiss_context_destroy(&context);
	 Cmiss_scene_viewer_destroy(&scene_viewer);
}

TEST(Cmiss_scene_viewer_api, set_background_invalid_args)
{
	ZincTestSetup z;

	Cmiss_scene_viewer_module_id svm = Cmiss_graphics_module_get_scene_viewer_module(z.gm);

	EXPECT_EQ(CMISS_ERROR_ARGUMENT, Cmiss_scene_viewer_set_background_colour_component_rgb(0, 0.0, 0.0, 0.0));

	Cmiss_scene_viewer_id sv = Cmiss_scene_viewer_module_create_scene_viewer(svm, CMISS_SCENE_VIEWER_BUFFERING_ANY_MODE, CMISS_SCENE_VIEWER_STEREO_ANY_MODE);
	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_set_background_colour_component_rgb(sv, -1.0, 0.2, 0.8));

	double rgb[3] = {-0.3, -1.0, 2.99};
	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_set_background_colour_rgb(sv, rgb));

	Cmiss_scene_viewer_destroy(&sv);
	Cmiss_scene_viewer_module_destroy(&svm);
}

TEST(Cmiss_scene_viewer_api, set_background_valid_args)
{
	ZincTestSetup z;

	Cmiss_scene_viewer_module_id svm = Cmiss_graphics_module_get_scene_viewer_module(z.gm);

	Cmiss_scene_viewer_id sv = Cmiss_scene_viewer_module_create_scene_viewer(svm, CMISS_SCENE_VIEWER_BUFFERING_ANY_MODE, CMISS_SCENE_VIEWER_STEREO_ANY_MODE);
	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_set_background_colour_component_rgb(sv, 0.5, 0.2, 0.8));

	double rgb[3] = {0.3, 1.0, 0.99};
	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_set_background_colour_rgb(sv, rgb));

	Cmiss_scene_viewer_destroy(&sv);
	Cmiss_scene_viewer_module_destroy(&svm);
}

TEST(Cmiss_scene_viewer_api, get_background_rgb)
{
	ZincTestSetup z;
	double rgb[3] = {0.0, 0.0, 0.0};

	EXPECT_EQ(CMISS_ERROR_ARGUMENT, Cmiss_scene_viewer_set_background_colour_component_rgb(0, 0.5, 0.2, 0.8));

	Cmiss_scene_viewer_module_id svm = Cmiss_graphics_module_get_scene_viewer_module(z.gm);

	Cmiss_scene_viewer_id sv = Cmiss_scene_viewer_module_create_scene_viewer(svm, CMISS_SCENE_VIEWER_BUFFERING_ANY_MODE, CMISS_SCENE_VIEWER_STEREO_ANY_MODE);
	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_set_background_colour_component_rgb(sv, 0.5, 0.2, 0.8));
	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_get_background_colour_rgb(sv, rgb));

	EXPECT_EQ(0.5, rgb[0]);
	EXPECT_EQ(0.2, rgb[1]);
	EXPECT_EQ(0.8, rgb[2]);

	Cmiss_scene_viewer_destroy(&sv);
	Cmiss_scene_viewer_module_destroy(&svm);
}
<commit_msg>Adding invalid args tests to get_background_rgb.  https://tracker.physiomeproject.org/show_bug.cgi?id=3361<commit_after>#include <gtest/gtest.h>

#include <zinc/zincconfigure.h>
#include <zinc/status.h>
#include <zinc/core.h>
#include <zinc/context.h>
#include <zinc/sceneviewer.h>

#include "zinctestsetup.hpp"

TEST(Cmiss_scene_viewer_api, destroy_context_before_scene_viewer)
{
	 Cmiss_context_id context = Cmiss_context_create("test");
	 Cmiss_graphics_module_id gm = Cmiss_context_get_graphics_module(context);
	 Cmiss_scene_viewer_module_id scene_viewer_module = Cmiss_graphics_module_get_scene_viewer_module(gm);
	 Cmiss_scene_viewer_id scene_viewer = Cmiss_scene_viewer_module_create_scene_viewer(scene_viewer_module,
	  CMISS_SCENE_VIEWER_BUFFERING_ANY_MODE, CMISS_SCENE_VIEWER_STEREO_ANY_MODE);
	 Cmiss_scene_viewer_module_destroy(&scene_viewer_module);
	 Cmiss_graphics_module_destroy(&gm);
	 Cmiss_context_destroy(&context);
	 Cmiss_scene_viewer_destroy(&scene_viewer);
}

TEST(Cmiss_scene_viewer_api, set_background_invalid_args)
{
	ZincTestSetup z;

	Cmiss_scene_viewer_module_id svm = Cmiss_graphics_module_get_scene_viewer_module(z.gm);
	Cmiss_scene_viewer_id sv = Cmiss_scene_viewer_module_create_scene_viewer(svm, CMISS_SCENE_VIEWER_BUFFERING_ANY_MODE, CMISS_SCENE_VIEWER_STEREO_ANY_MODE);

	EXPECT_EQ(CMISS_ERROR_ARGUMENT, Cmiss_scene_viewer_set_background_colour_component_rgb(0, 0.0, 0.0, 0.0));

	EXPECT_EQ(CMISS_ERROR_ARGUMENT, Cmiss_scene_viewer_set_background_colour_rgb(0, 0));

	EXPECT_EQ(CMISS_ERROR_ARGUMENT, Cmiss_scene_viewer_set_background_colour_rgb(sv, 0));

	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_set_background_colour_component_rgb(sv, -1.0, 0.2, 0.8));

	double rgb[3] = {-0.3, -1.0, 2.99};
	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_set_background_colour_rgb(sv, rgb));

	Cmiss_scene_viewer_destroy(&sv);
	Cmiss_scene_viewer_module_destroy(&svm);
}

TEST(Cmiss_scene_viewer_api, set_background_valid_args)
{
	ZincTestSetup z;

	Cmiss_scene_viewer_module_id svm = Cmiss_graphics_module_get_scene_viewer_module(z.gm);

	Cmiss_scene_viewer_id sv = Cmiss_scene_viewer_module_create_scene_viewer(svm, CMISS_SCENE_VIEWER_BUFFERING_ANY_MODE, CMISS_SCENE_VIEWER_STEREO_ANY_MODE);
	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_set_background_colour_component_rgb(sv, 0.5, 0.2, 0.8));

	double rgb[3] = {0.3, 1.0, 0.99};
	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_set_background_colour_rgb(sv, rgb));

	Cmiss_scene_viewer_destroy(&sv);
	Cmiss_scene_viewer_module_destroy(&svm);
}

TEST(Cmiss_scene_viewer_api, get_background_rgb_invalid_args)
{
	ZincTestSetup z;
	Cmiss_scene_viewer_module_id svm = Cmiss_graphics_module_get_scene_viewer_module(z.gm);
	Cmiss_scene_viewer_id sv = Cmiss_scene_viewer_module_create_scene_viewer(svm, CMISS_SCENE_VIEWER_BUFFERING_ANY_MODE, CMISS_SCENE_VIEWER_STEREO_ANY_MODE);

	EXPECT_EQ(CMISS_ERROR_ARGUMENT, Cmiss_scene_viewer_get_background_colour_rgb(0, 0));
	EXPECT_EQ(CMISS_ERROR_ARGUMENT, Cmiss_scene_viewer_get_background_colour_rgb(sv, 0));

	Cmiss_scene_viewer_destroy(&sv);
	Cmiss_scene_viewer_module_destroy(&svm);
}

TEST(Cmiss_scene_viewer_api, get_background_rgb)
{
	ZincTestSetup z;
	double rgb[3] = {0.0, 0.0, 0.0};

	Cmiss_scene_viewer_module_id svm = Cmiss_graphics_module_get_scene_viewer_module(z.gm);
	Cmiss_scene_viewer_id sv = Cmiss_scene_viewer_module_create_scene_viewer(svm, CMISS_SCENE_VIEWER_BUFFERING_ANY_MODE, CMISS_SCENE_VIEWER_STEREO_ANY_MODE);

	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_set_background_colour_component_rgb(sv, 0.5, 0.2, 0.8));
	EXPECT_EQ(CMISS_OK, Cmiss_scene_viewer_get_background_colour_rgb(sv, rgb));

	EXPECT_EQ(0.5, rgb[0]);
	EXPECT_EQ(0.2, rgb[1]);
	EXPECT_EQ(0.8, rgb[2]);

	Cmiss_scene_viewer_destroy(&sv);
	Cmiss_scene_viewer_module_destroy(&svm);
}

{'fraction_non_alphanumeric': 0.09345932378561937, 'fraction_numerical': 0.019341503026723755, 'mean_word_length': 10.639175257731958, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 1, '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': '2065598', 'n_tokens_mistral': 3013, 'n_tokens_neox': 2829, 'n_words': 289}