/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ Franz Wilhelmstötter
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author:
 *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmx.at)
 */
package org.jenetics;

import org.testng.Assert;
import org.testng.annotations.Test;

import org.jenetics.util.MSeq;
import org.jenetics.util.ObjectTester;

/**
 * @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
 * @version <em>$Date: 2014-07-01 $</em>
 */
public abstract class GeneTester<G extends Gene<?, G>> extends ObjectTester<G> {

	@Test
	public void equalsAllele() {
		final MSeq<G> same = newSameObjects(5);

		final G that = same.get(0);
		for (int i = 1; i < same.length(); ++i) {
			final G other = same.get(i);

			Assert.assertEquals(other.getAllele(), other.getAllele());
			Assert.assertEquals(other.getAllele(), that.getAllele());
			Assert.assertEquals(that.getAllele(), other.getAllele());
			Assert.assertFalse(other.getAllele().equals(null));
		}
	}

	@Test
	public void notEqualsAllele() {
		for (int i = 0; i < 10; ++i) {
			final Object that = factory().newInstance().getAllele();
			final Object other = factory().newInstance().getAllele();

			if (that.equals(other)) {
				Assert.assertTrue(other.equals(that));
				Assert.assertEquals(that.hashCode(), other.hashCode());
			} else {
				Assert.assertFalse(other.equals(that));
				Assert.assertFalse(that.equals(other));
			}
		}
	}

}

@@ -1104,16 +1104,405 @@
 r%3CG%3E %7B%0A%0A
+%09@Test%0A%09public void newInstance() %7B%0A%09%09for (int i = 0; i %3C 1000; ++i) %7B%0A%09%09%09final G gene = factory().newInstance();%0A%09%09%09Assert.assertNotNull(gene);%0A%09%09%09Assert.assertNotNull(gene.getAllele());%0A%09%09%09Assert.assertTrue(gene.isValid());%0A%0A%09%09%09final G gene2 = gene.newInstance();%0A%09%09%09Assert.assertNotNull(gene2);%0A%09%09%09Assert.assertNotNull(gene2.getAllele());%0A%09%09%09Assert.assertTrue(gene2.isValid());%0A%09%09%7D%0A%09%7D%0A%0A
 %09@Test%0A%09
@@ -1870,45 +1870,285 @@
 ;%0A%09%09
-%09Assert.assertFalse(other.getAllele()
+%7D%0A%09%7D%0A%0A%09@Test%0A%09public void alleleNotNull() %7B%0A%09%09for (int i = 0; i %3C 1000; ++i) %7B%0A%09%09%09Assert.assertNotNull(factory().newInstance().getAllele());%0A%09%09%7D%0A%09%7D%0A%0A%09@Test%0A%09public void notEqualsAlleleNull() %7B%0A%09%09final Object that = factory().newInstance().getAllele();%0A%09%09Assert.assertFalse(that
 .equ
@@ -2155,28 +2155,24 @@
 als(null));%0A
-%09%09%7D%0A
 %09%7D%0A%0A%09@Test%0A%09
@@ -2227,16 +2227,18 @@
 ; i %3C 10
+00
 ; ++i) %7B

Improve tests.