<commit_before>/*
 * Copyright 2019 <NAME> <<EMAIL>>
 * All rights reserved. Distributed under the terms of the MIT license.
 */


#include <gtest/gtest.h>

#include <Application.h>
#include <GroupLayout.h>
#include <ScintillaView.h>
#include <Window.h>

#include "editor/FindReplaceHandler.h"


class FindReplaceTest : public ::testing::Test
{
protected:
	BApplication* fApplication;
	BWindow* fWindow;
	BScintillaView* fEditor;
	FindReplaceHandler* fFindReplaceHandler;
	BMessenger* fMessenger;

	void SetUp() override;
	void TearDown() override;
};


void
FindReplaceTest::SetUp()
{
	fApplication = new BApplication("application/x-vnd.KapiX-KoderFindReplaceTest");
	fWindow = new BWindow(BRect(100, 100, 400, 400), "FindReplaceTest", B_DOCUMENT_WINDOW, 0);
	fEditor = new BScintillaView("EditorView", 0, true, true, B_NO_BORDER);
	fEditor->SetText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
		"Duis congue aliquam eros eget rhoncus. Mauris ultricies ipsum urna, "
		"vitae scelerisque lacus facilisis molestie. Curabitur pulvinar "
		"imperdiet nibh ut lacinia. Donec a dictum sapien, id rhoncus ex. "
		"Integer et lorem malesuada, sagittis massa nec, imperdiet ante. "
		"Pellentesque quis lectus dolor. Vestibulum ante ipsum primis in "
		"faucibus orci luctus et ultrices posuere cubilia Curae; Cras ac purus "
		"auctor, mattis risus eu, ultricies lectus.");
	fFindReplaceHandler = new FindReplaceHandler(fEditor, fWindow);
	fWindow->AddHandler(fFindReplaceHandler);
	BGroupLayout *layout = new BGroupLayout(B_VERTICAL, 0);
	fWindow->SetLayout(layout);
	fWindow->Show();
	layout->AddView(fEditor);
	fMessenger = new BMessenger(fFindReplaceHandler, fWindow);
}


void
FindReplaceTest::TearDown()<commit_msg>Fix unit tests<commit_after>/*
 * Copyright 2019 <NAME> <<EMAIL>>
 * All rights reserved. Distributed under the terms of the MIT license.
 */


#include <gtest/gtest.h>

#include <Application.h>
#include <GroupLayout.h>
#include <ScintillaView.h>
#include <Window.h>

#include "editor/FindReplaceHandler.h"


class FindReplaceTest : public ::testing::Test
{
protected:
	BApplication* fApplication;
	BWindow* fWindow;
	BScintillaView* fEditor;
	FindReplaceHandler* fFindReplaceHandler;
	BMessenger* fMessenger;

	void SetUp() override;
	void TearDown() override;
};


void
FindReplaceTest::SetUp()
{
	fApplication = new BApplication("application/x-vnd.KapiX-KoderFindReplaceTest");
	fWindow = new BWindow(BRect(100, 100, 400, 400), "FindReplaceTest", B_DOCUMENT_WINDOW, 0);
	fEditor = new BScintillaView("EditorView", 0, true, true, B_NO_BORDER);
	fFindReplaceHandler = new FindReplaceHandler(fEditor, fWindow);
	fWindow->AddHandler(fFindReplaceHandler);
	BGroupLayout *layout = new BGroupLayout(B_VERTICAL, 0);
	fWindow->SetLayout(layout);
	fWindow->Show();
	layout->AddView(fEditor);
	fMessenger = new BMessenger(fFindReplaceHandler, fWindow);

	fEditor->LockLooper();
	fEditor->SetText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
		"Duis congue aliquam eros eget rhoncus. Mauris ultricies ipsum urna, "
		"vitae scelerisque lacus facilisis molestie. Curabitur pulvinar "
		"imperdiet nibh ut lacinia. Donec a dictum sapien, id rhoncus ex. "
		"Integer et lorem malesuada, sagittis massa nec, imperdiet ante. "
		"Pellentesque quis lectus dolor. Vestibulum ante ipsum primis in "
		"faucibus orci luctus et ultrices posuere cubilia Curae; Cras ac purus "
		"auctor, mattis risus eu, ultricies lectus.");
	fEditor->UnlockLooper();
}


void
FindReplaceTest::TearDown()
{'fraction_non_alphanumeric': 0.10813887307911212, 'fraction_numerical': 0.010813887307911212, 'mean_word_length': 5.759615384615385, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '206396', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1226, 'n_words': 323}