<commit_before>/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 2013 <NAME>
 * Written (W) 2014 <NAME>
 */

#include <shogun/labels/BinaryLabels.h>
#include <shogun/labels/RegressionLabels.h>
#ifdef HAVE_EIGEN3
#include <shogun/features/DenseFeatures.h>
#include <shogun/kernel/GaussianKernel.h>
#include <shogun/regression/GaussianProcessRegression.h>
#include <shogun/machine/gp/ExactInferenceMethod.h>
#include <shogun/machine/gp/ZeroMean.h>
#include <shogun/machine/gp/GaussianLikelihood.h>
#endif
#include <shogun/io/SerializableAsciiFile.h>
#include <shogun/statistics/QuadraticTimeMMD.h>
#include <pthread.h>
#include <gtest/gtest.h>

using namespace shogun;

#ifdef HAVE_EIGEN3
TEST(SGObject,equals_same)
{
	CGaussianKernel* kernel=new CGaussianKernel();
	EXPECT_TRUE(kernel->equals(kernel));
	SG_UNREF(kernel);
}

TEST(SGObject,equals_NULL_parameter)
{
	SGMatrix<float64_t> data(3,10);
	for (index_t i=0; i<data.num_rows*data.num_cols; ++i)
		data.matrix[i]=CMath::randn_double();

	CDenseFeatures<float64_t>* feats=new CDenseFeatures<float64_t>(data);
	CGaussianKernel* kernel=new CGaussianKernel();
	CQuadraticTimeMMD* mmd=new CQuadraticTimeMMD(kernel, feats, 5);
	CQuadraticTimeMMD* mmd2=new CQuadraticTimeMMD(NULL, feats, 5);

	mmd->equals(mmd2);

	SG_UNREF(mmd);
	SG_UNREF(mmd2);
}
#endif //HAVE_EIGEN3

void* stress_test(void* args)
{
	CBinaryLabels* labs = (CBinaryLabels* ) args;
	CBinaryLabels* labs_2 = new CBinaryLabels(*labs);
	for (index_t i=0; i<1000000; i++)
	{
		SG_REF(labs);
		SG_REF(labs_2);
		SG_UNREF(labs_2);
		SG_UNREF(labs);
	}
	SG_UNREF(labs_2);
	pthread_exit(0);
}

#ifdef USE_REFERENCE_COUNTING
TEST(SGObject,DISABLED_ref_copy_constructor)
{
	CBinaryLabels* labs = new CBinaryLabels(10);
	EXPECT_EQ(labs->ref_count(), 0);

	SG_REF(labs);
	EXPECT_EQ(labs->ref_count(), 1);

	// TODO: This causes memory corruptions; disabled test until fixed
	CBinaryLabels* labs_2 = new CBinaryLabels(*labs);
	SG_UNREF(labs_2);
<commit_msg>Removing obsolete test helper stress_test() - which is now in RefCount_unittest.<commit_after>/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 2013 <NAME>
 * Written (W) 2014 <NAME>
 */

#include <shogun/labels/BinaryLabels.h>
#include <shogun/labels/RegressionLabels.h>
#ifdef HAVE_EIGEN3
#include <shogun/features/DenseFeatures.h>
#include <shogun/kernel/GaussianKernel.h>
#include <shogun/regression/GaussianProcessRegression.h>
#include <shogun/machine/gp/ExactInferenceMethod.h>
#include <shogun/machine/gp/ZeroMean.h>
#include <shogun/machine/gp/GaussianLikelihood.h>
#endif
#include <shogun/io/SerializableAsciiFile.h>
#include <shogun/statistics/QuadraticTimeMMD.h>
#include <pthread.h>
#include <gtest/gtest.h>

using namespace shogun;

#ifdef HAVE_EIGEN3
TEST(SGObject,equals_same)
{
	CGaussianKernel* kernel=new CGaussianKernel();
	EXPECT_TRUE(kernel->equals(kernel));
	SG_UNREF(kernel);
}

TEST(SGObject,equals_NULL_parameter)
{
	SGMatrix<float64_t> data(3,10);
	for (index_t i=0; i<data.num_rows*data.num_cols; ++i)
		data.matrix[i]=CMath::randn_double();

	CDenseFeatures<float64_t>* feats=new CDenseFeatures<float64_t>(data);
	CGaussianKernel* kernel=new CGaussianKernel();
	CQuadraticTimeMMD* mmd=new CQuadraticTimeMMD(kernel, feats, 5);
	CQuadraticTimeMMD* mmd2=new CQuadraticTimeMMD(NULL, feats, 5);

	mmd->equals(mmd2);

	SG_UNREF(mmd);
	SG_UNREF(mmd2);
}
#endif //HAVE_EIGEN3

#ifdef USE_REFERENCE_COUNTING
TEST(SGObject,DISABLED_ref_copy_constructor)
{
	CBinaryLabels* labs = new CBinaryLabels(10);
	EXPECT_EQ(labs->ref_count(), 0);

	SG_REF(labs);
	EXPECT_EQ(labs->ref_count(), 1);

	// TODO: This causes memory corruptions; disabled test until fixed
	CBinaryLabels* labs_2 = new CBinaryLabels(*labs);
	SG_UNREF(labs_2);

{'fraction_non_alphanumeric': 0.12771084337349398, 'fraction_numerical': 0.019036144578313253, 'mean_word_length': 6.439068100358423, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 45, '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': '1770070', 'n_tokens_mistral': 1668, 'n_tokens_neox': 1579, 'n_words': 319}