blob: a98f8b3c34332b77fcf8633830ff6576b2021f9f [file] [log] [blame]
[comment]
Copyright 2010 Obeo
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 1.0
Any license can be applied to the files generated with this template.
author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
[/comment]
[module EnumerationTest('http://www.eclipse.org/emf/2002/GenModel')/]
[import Common/]
[template public enumerationTest(enum : GenEnum)]
[file ('src-gen/'.concat(enum.testPackage().substituteAll('.', '/').concat('/unit/')).concat(enum.ecoreEnum.name.toUpperFirst()).concat('Test.java'), false)]
package [enum.testPackage().concat('.unit')/];
import junit.framework.TestCase;
import [enum.modelPackage()/].[enum.ecoreEnum.name.toUpperFirst()/];
/**
* Tests the behavior of the {@link [enum.ecoreEnum.name.toUpperFirst()/]} enumeration.
*
* @generated
*/
@SuppressWarnings("nls")
public class [enum.ecoreEnum.name.toUpperFirst()/]Test extends TestCase {
/**
* Tests the behavior of the {@link [enum.ecoreEnum.name.toUpperFirst()/]#get(int)} method.
*
* @generated
*/
public void testGetInt() {
int highestValue = -1;
for ([enum.ecoreEnum.name.toUpperFirst()/] value : [enum.ecoreEnum.name.toUpperFirst()/].VALUES) {
assertSame([enum.ecoreEnum.name.toUpperFirst()/].get(value.getValue()), value);
if (value.getValue() > highestValue) {
highestValue = value.getValue();
}
}
assertNull([enum.ecoreEnum.name.toUpperFirst()/].get(++highestValue));
}
/**
* Tests the behavior of the {@link [enum.ecoreEnum.name.toUpperFirst()/]#get(java.lang.String)} method.
*
* @generated
*/
public void testGetString() {
for ([enum.ecoreEnum.name.toUpperFirst()/] value : [enum.ecoreEnum.name.toUpperFirst()/].VALUES) {
assertSame([enum.ecoreEnum.name.toUpperFirst()/].get(value.getLiteral()), value);
}
assertNull([enum.ecoreEnum.name.toUpperFirst()/].get("ThisIsNotAValueOfTheTestedEnum"));
}
/**
* Tests the behavior of the {@link [enum.ecoreEnum.name.toUpperFirst()/]#getByName(java.lang.String)} method.
*
* @generated
*/
public void testGetByName() {
for ([enum.ecoreEnum.name.toUpperFirst()/] value : [enum.ecoreEnum.name.toUpperFirst()/].VALUES) {
assertSame([enum.ecoreEnum.name.toUpperFirst()/].getByName(value.getName()), value);
}
assertNull([enum.ecoreEnum.name.toUpperFirst()/].getByName("ThisIsNotTheNameOfAValueFromTheTestedEnum"));
}
}
[/file]
[/template]