|
From: <th...@us...> - 2008-12-31 18:49:35
|
Revision: 8757
http://pcgen.svn.sourceforge.net/pcgen/?rev=8757&view=rev
Author: thpr
Date: 2008-12-31 18:49:31 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
additional token tests
Modified Paths:
--------------
Trunk/pcgen/code/src/utest/plugin/lsttokens/TypeLstTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/VFeatLstTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalFormulaTokenTestCase.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalListTokenTestCase.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalStringTokenTestCase.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalTypeSafeListTestCase.java
Added Paths:
-----------
Trunk/pcgen/code/src/utest/plugin/lsttokens/RegionLstTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/SabLstTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/SelectTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcelongLstTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcepageLstTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/SourceshortLstTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcewebLstTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/SpellsLstTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/SrLstTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/UdamLstTest.java
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/RegionLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/RegionLstTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/RegionLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import org.junit.Test;
+
+import pcgen.cdom.base.CDOMObject;
+import pcgen.cdom.list.ClassSkillList;
+import pcgen.core.Domain;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.context.LoadContext;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class RegionLstTest extends AbstractGlobalTokenTestCase
+{
+ static RegionLst token = new RegionLst();
+ static CDOMTokenLoader<Domain> loader = new CDOMTokenLoader<Domain>(
+ Domain.class);
+
+ @Override
+ public Class<Domain> getCDOMClass()
+ {
+ return Domain.class;
+ }
+
+ @Override
+ public CDOMLoader<Domain> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testInvalidInputOnlyNumber() throws PersistenceLayerException
+ {
+ assertFalse(parse("1"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidInputNaN() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ assertFalse(parse("NaN|TestWP1"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidNoObject() throws PersistenceLayerException
+ {
+ assertFalse(parse("1|"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidNoCount() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ assertFalse(parse("|TestWP1"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidDoublePipe() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ assertFalse(parse("1||TestWP1"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidInputNoCount() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ construct(primaryContext, "TestWP2");
+ assertFalse(parse("|TestWP1|TestWP2"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidListEnd() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ assertFalse(parse("1|TestWP1|"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidZeroCount() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ assertFalse(parse("0|TestWP1"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidNegativeCount() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ construct(primaryContext, "TestWP2");
+ assertFalse(parse("-1|TestWP1|TestWP2"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidListDoubleJoin() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ construct(primaryContext, "TestWP2");
+ assertFalse(parse("1|TestWP2||TestWP1"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testValidInputs() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ construct(primaryContext, "TestWP2");
+ assertTrue(parse("1|TestWP1"));
+ assertTrue(primaryContext.ref.validate());
+ assertTrue(parse("1|TestWP1|TestWP2"));
+ assertTrue(primaryContext.ref.validate());
+ assertTrue(primaryContext.ref.validate());
+ assertTrue(parse("2|TestWP1|TestWP2"));
+ assertTrue(primaryContext.ref.validate());
+ }
+
+ @Test
+ public void testRoundRobinOne() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ construct(primaryContext, "TestWP2");
+ construct(secondaryContext, "TestWP1");
+ construct(secondaryContext, "TestWP2");
+ runRoundRobin("TestWP1");
+ }
+
+ @Test
+ public void testRoundRobinTwo() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ construct(primaryContext, "TestWP2");
+ construct(secondaryContext, "TestWP1");
+ construct(secondaryContext, "TestWP2");
+ runRoundRobin("TestWP1|TestWP2");
+ }
+
+ @Test
+ public void testRoundRobinThree() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ construct(primaryContext, "TestWP2");
+ construct(primaryContext, "TestWP3");
+ construct(secondaryContext, "TestWP1");
+ construct(secondaryContext, "TestWP2");
+ construct(secondaryContext, "TestWP3");
+ runRoundRobin("2|TestWP1|TestWP2|TestWP3");
+ }
+
+ protected void construct(LoadContext loadContext, String one)
+ {
+ loadContext.ref.constructCDOMObject(ClassSkillList.class, one);
+ }
+
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/SabLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/SabLstTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/SabLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import java.net.URISyntaxException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import pcgen.cdom.base.CDOMObject;
+import pcgen.core.PCTemplate;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+import plugin.lsttokens.testsupport.TokenRegistration;
+import plugin.pretokens.parser.PreClassParser;
+import plugin.pretokens.parser.PreRaceParser;
+import plugin.pretokens.writer.PreClassWriter;
+import plugin.pretokens.writer.PreRaceWriter;
+
+public class SabLstTest extends AbstractGlobalTokenTestCase
+{
+ static CDOMPrimaryToken<CDOMObject> token = new SabLst();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ PreClassParser preclass = new PreClassParser();
+ PreClassWriter preclasswriter = new PreClassWriter();
+ PreRaceParser prerace = new PreRaceParser();
+ PreRaceWriter preracewriter = new PreRaceWriter();
+
+ @Override
+ @Before
+ public void setUp() throws PersistenceLayerException, URISyntaxException
+ {
+ super.setUp();
+ TokenRegistration.register(preclass);
+ TokenRegistration.register(prerace);
+ TokenRegistration.register(preclasswriter);
+ TokenRegistration.register(preracewriter);
+ }
+
+ @Test
+ public void testInvalidDoublePipe() throws PersistenceLayerException
+ {
+ assertFalse(parse("SA Number %||VarF"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEndingPipe() throws PersistenceLayerException
+ {
+ assertFalse(parse("SA Number|"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidStartingPipe() throws PersistenceLayerException
+ {
+ assertFalse(parse("|Var"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidVarAfterPre() throws PersistenceLayerException
+ {
+ assertFalse(parse("SA % plus %|Var|PRECLASS:1,Fighter|Var2"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidDotClear() throws PersistenceLayerException
+ {
+ assertFalse(parse("SA % plus %|Var|.CLEAR|Var2"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidOnlyPre() throws PersistenceLayerException
+ {
+ assertFalse(parse("PRECLASS:1,Fighter"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testRoundRobinBase() throws PersistenceLayerException
+ {
+ runRoundRobin("SA Number One");
+ }
+
+ @Test
+ public void testRoundRobinVariable() throws PersistenceLayerException
+ {
+ runRoundRobin("SA Number %|Variab");
+ }
+
+ @Test
+ public void testRoundRobinPre() throws PersistenceLayerException
+ {
+ runRoundRobin("SA Number One|PRECLASS:1,Fighter=1");
+ }
+
+ @Test
+ public void testRoundRobinDoublePre() throws PersistenceLayerException
+ {
+ runRoundRobin("SA Number One|PRECLASS:1,Fighter=1|PRERACE:1,Human");
+ }
+
+ @Test
+ public void testRoundRobinVarDoublePre() throws PersistenceLayerException
+ {
+ runRoundRobin("SA Number % before %|Var|TwoVar|PRECLASS:1,Fighter=1|PRERACE:1,Human");
+ }
+
+ @Test
+ public void testRoundRobinCompound() throws PersistenceLayerException
+ {
+ runRoundRobin(
+ "SA Number % before %|Var|TwoVar|PRECLASS:1,Fighter=1|PRERACE:1,Human",
+ "SA Number One|PRECLASS:1,Fighter=1");
+ }
+
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/SelectTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/SelectTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/SelectTokenTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import pcgen.cdom.base.CDOMObject;
+import pcgen.cdom.enumeration.FormulaKey;
+import pcgen.core.PCTemplate;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalFormulaTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class SelectTokenTest extends AbstractGlobalFormulaTokenTestCase
+{
+
+ static SelectLst token = new SelectLst();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ @Override
+ public FormulaKey getFormulaKey()
+ {
+ return FormulaKey.SELECT;
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcelongLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcelongLstTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcelongLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import pcgen.cdom.base.CDOMObject;
+import pcgen.cdom.enumeration.StringKey;
+import pcgen.core.PCTemplate;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalStringTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class SourcelongLstTest extends AbstractGlobalStringTokenTestCase
+{
+
+ static SourcelongLst token = new SourcelongLst();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ @Override
+ public StringKey getStringKey()
+ {
+ return StringKey.SOURCE_LONG;
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcepageLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcepageLstTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcepageLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import pcgen.cdom.base.CDOMObject;
+import pcgen.cdom.enumeration.StringKey;
+import pcgen.core.PCTemplate;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalStringTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class SourcepageLstTest extends AbstractGlobalStringTokenTestCase
+{
+
+ static SourcepageLst token = new SourcepageLst();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ @Override
+ public StringKey getStringKey()
+ {
+ return StringKey.SOURCE_PAGE;
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/SourceshortLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/SourceshortLstTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/SourceshortLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import pcgen.cdom.base.CDOMObject;
+import pcgen.cdom.enumeration.StringKey;
+import pcgen.core.PCTemplate;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalStringTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class SourceshortLstTest extends AbstractGlobalStringTokenTestCase
+{
+
+ static SourceshortLst token = new SourceshortLst();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ @Override
+ public StringKey getStringKey()
+ {
+ return StringKey.SOURCE_SHORT;
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcewebLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcewebLstTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/SourcewebLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import pcgen.cdom.base.CDOMObject;
+import pcgen.cdom.enumeration.StringKey;
+import pcgen.core.PCTemplate;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalStringTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class SourcewebLstTest extends AbstractGlobalStringTokenTestCase
+{
+
+ static SourcewebLst token = new SourcewebLst();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ @Override
+ public StringKey getStringKey()
+ {
+ return StringKey.SOURCE_WEB;
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/SpellsLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/SpellsLstTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/SpellsLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import java.net.URISyntaxException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import pcgen.cdom.base.CDOMObject;
+import pcgen.core.PCTemplate;
+import pcgen.core.SettingsHandler;
+import pcgen.core.TimeUnit;
+import pcgen.core.spell.Spell;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+import plugin.lsttokens.testsupport.TokenRegistration;
+import plugin.pretokens.parser.PreClassParser;
+import plugin.pretokens.parser.PreRaceParser;
+import plugin.pretokens.writer.PreClassWriter;
+import plugin.pretokens.writer.PreRaceWriter;
+
+public class SpellsLstTest extends AbstractGlobalTokenTestCase
+{
+
+ static CDOMPrimaryToken<CDOMObject> token = new SpellsLst();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ PreClassParser preclass = new PreClassParser();
+ PreClassWriter preclasswriter = new PreClassWriter();
+ PreRaceParser prerace = new PreRaceParser();
+ PreRaceWriter preracewriter = new PreRaceWriter();
+
+ @Override
+ @Before
+ public void setUp() throws PersistenceLayerException, URISyntaxException
+ {
+ super.setUp();
+ TokenRegistration.register(preclass);
+ TokenRegistration.register(preclasswriter);
+ TokenRegistration.register(prerace);
+ TokenRegistration.register(preracewriter);
+ primaryContext.ref.constructCDOMObject(Spell.class, "Fireball");
+ primaryContext.ref.constructCDOMObject(Spell.class, "Lightning Bolt");
+ secondaryContext.ref.constructCDOMObject(Spell.class, "Fireball");
+ secondaryContext.ref.constructCDOMObject(Spell.class, "Lightning Bolt");
+ SettingsHandler.getGame().addTimeUnit(new TimeUnit("Week"));
+ SettingsHandler.getGame().addTimeUnit(new TimeUnit("Hour"));
+ SettingsHandler.getGame().addTimeUnit(new TimeUnit("Day"));
+ }
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testInvalidEmpty() throws PersistenceLayerException
+ {
+ assertFalse(parse(""));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidSpellbookOnly() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidSpellbookBarOnly() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptySpellbook() throws PersistenceLayerException
+ {
+ assertFalse(parse("|Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidSpellbookAndSpellBarOnly()
+ throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|Fireball|"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidSpellCommaStarting()
+ throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|,Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidSpellCommaEnding() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|Fireball,"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidSpellDoubleComma() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|Fireball,,DCFormula"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidSpellDoublePipe() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|Fireball||Lightning Bolt"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidSpellEmbeddedPre() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|Fireball|PRERACE:1,Human|Lightning Bolt"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidBadTimes() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|TIMES=|Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidOnlyTimes() throws PersistenceLayerException
+ {
+ try
+ {
+ assertFalse(parse("SpellBook|TIMES=3"));
+ }
+ catch (IllegalArgumentException iae)
+ {
+ // OK
+ }
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidOnlyTimesBar() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|TIMES=3|"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidOnlyLevel() throws PersistenceLayerException
+ {
+ try
+ {
+ assertFalse(parse("SpellBook|CASTERLEVEL=3"));
+ }
+ catch (IllegalArgumentException iae)
+ {
+ // This is ok too
+ }
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyTimeUnit() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|TIMEUNIT=|Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidTwoTimeUnit() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|TIMEUNIT=Hour|TIMEUNIT=Day|Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidTimeUnit() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|TIMEUNIT=Fortnight|Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidTimeUnitNoSpell() throws PersistenceLayerException
+ {
+ try
+ {
+ assertFalse(parse("SpellBook|TIMEUNIT=Day"));
+ }
+ catch (IllegalArgumentException iae)
+ {
+ // This is ok too
+ }
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyTimes() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|TIMES=|Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyCasterLevel() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|CASTERLEVEL=|Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidTwoTimes() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|TIMES=3|TIMES=4|Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidTwoCasterLevel() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|CASTERLEVEL=3|CASTERLEVEL=4|Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidOnlyLevelBar() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|CASTERLEVEL=3|"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidDoubleBar() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook||Fireball"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidBadCasterLevel() throws PersistenceLayerException
+ {
+ assertFalse(parse("SpellBook|CASTERLEVEL=|Fireball"));
+ assertNoSideEffects();
+ }
+
+ // @Test
+ // public void testInvalidOutOfOrder() throws PersistenceLayerException
+ // {
+ // try
+ // {
+ // assertFalse(parse("SpellBook|CASTERLEVEL=4|TIMES=2|Fireball"));
+ // }
+ // catch (IllegalArgumentException iae)
+ // {
+ // // This is ok too
+ // }
+ // assertNoSideEffects();
+ // }
+
+ @Test
+ public void testInvalidOnlyPre() throws PersistenceLayerException
+ {
+ try
+ {
+ assertFalse(parse("SpellBook|TIMES=2|PRERACE:1,Human"));
+ }
+ catch (IllegalArgumentException iae)
+ {
+ // This is ok too
+ }
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testRoundRobinJustSpell() throws PersistenceLayerException
+ {
+ runRoundRobin("SpellBook|Fireball");
+ }
+
+ @Test
+ public void testRoundRobinTwoSpell() throws PersistenceLayerException
+ {
+ runRoundRobin("SpellBook|Fireball|Lightning Bolt");
+ }
+
+ @Test
+ public void testRoundRobinTimes() throws PersistenceLayerException
+ {
+ runRoundRobin("SpellBook|TIMES=3|Fireball");
+ }
+
+ @Test
+ public void testRoundRobinDC() throws PersistenceLayerException
+ {
+ runRoundRobin("SpellBook|Fireball,CL+5");
+ }
+
+ @Test
+ public void testRoundRobinPre() throws PersistenceLayerException
+ {
+ runRoundRobin("SpellBook|Fireball|PRERACE:1,Human");
+ }
+
+ @Test
+ public void testRoundRobinTimeUnit() throws PersistenceLayerException
+ {
+ runRoundRobin("SpellBook|TIMEUNIT=Hour|Fireball");
+ }
+
+ @Test
+ public void testRoundRobinCasterLevel() throws PersistenceLayerException
+ {
+ runRoundRobin("SpellBook|CASTERLEVEL=15|Fireball");
+ }
+
+ @Test
+ public void testRoundRobinComplex() throws PersistenceLayerException
+ {
+ runRoundRobin("SpellBook|TIMES=2|TIMEUNIT=Week|CASTERLEVEL=15|Fireball,CL+5|Lightning Bolt,25|!PRECLASS:1,Cleric=1|PRERACE:1,Human");
+ }
+
+ @Test
+ public void testRoundRobinTwoBooksJustSpell()
+ throws PersistenceLayerException
+ {
+ runRoundRobin("OtherBook|Lightning Bolt", "SpellBook|Fireball");
+ }
+
+ @Test
+ public void testRoundRobinTwoTimesJustSpell()
+ throws PersistenceLayerException
+ {
+ runRoundRobin("SpellBook|TIMES=2|Fireball",
+ "SpellBook|TIMES=3|Lightning Bolt");
+ }
+
+ @Test
+ public void testRoundRobinTwoLevelJustSpell()
+ throws PersistenceLayerException
+ {
+ runRoundRobin("SpellBook|CASTERLEVEL=12|Fireball",
+ "SpellBook|CASTERLEVEL=15|Lightning Bolt");
+ }
+}
\ No newline at end of file
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/SrLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/SrLstTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/SrLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import pcgen.base.formula.Formula;
+import pcgen.cdom.base.CDOMObject;
+import pcgen.cdom.enumeration.FormulaKey;
+import pcgen.cdom.enumeration.ObjectKey;
+import pcgen.core.PCTemplate;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalFormulaTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class SrLstTest extends AbstractGlobalFormulaTokenTestCase
+{
+
+ static SrLst token = new SrLst();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ @Override
+ public FormulaKey getFormulaKey()
+ {
+ return null;
+ }
+
+ @Override
+ protected Formula getFormula()
+ {
+ return primaryProf.get(ObjectKey.SR).getReduction();
+ }
+
+}
Modified: Trunk/pcgen/code/src/utest/plugin/lsttokens/TypeLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/TypeLstTest.java 2008-12-31 18:48:56 UTC (rev 8756)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/TypeLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -81,7 +81,7 @@
@Override
public boolean isClearLegal()
{
- return false;
+ return true;
}
@Test
@@ -148,4 +148,37 @@
assertFalse(parse("TestWP1.REMOVE.ADD.TestWP2"));
assertNoSideEffects();
}
+
+ @Test
+ public void testInputInvalidEmbeddedClear() throws PersistenceLayerException
+ {
+ assertFalse(parse("TestWP1.CLEAR.TestWP2"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInputInvalidDotClearDot() throws PersistenceLayerException
+ {
+ assertFalse(parse(".CLEAR."));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInputInvalidDotClearStuff() throws PersistenceLayerException
+ {
+ assertFalse(parse(".CLEARSTUFF"));
+ assertNoSideEffects();
+ }
+
+ @Override
+ protected boolean isAllLegal()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean requiresPreconstruction()
+ {
+ return false;
+ }
}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/UdamLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/UdamLstTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/UdamLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import org.junit.Test;
+
+import pcgen.cdom.base.CDOMObject;
+import pcgen.core.PCTemplate;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class UdamLstTest extends AbstractGlobalTokenTestCase
+{
+ static CDOMPrimaryToken<CDOMObject> token = new UdamLst();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testInvalidNotEnoughValues() throws PersistenceLayerException
+ {
+ assertFalse(parse("1,2,3,4,5,6,7,8"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidTooManyValues() throws PersistenceLayerException
+ {
+ assertFalse(parse("1,2,3,4,5,6,7,8,9,0"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyValue1() throws PersistenceLayerException
+ {
+ assertFalse(parse(",2,3,4,5,6,7,8,9"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyValue2() throws PersistenceLayerException
+ {
+ assertFalse(parse("1,,3,4,5,6,7,8,9"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyValue3() throws PersistenceLayerException
+ {
+ assertFalse(parse("1,2,,4,5,6,7,8,9"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyValue4() throws PersistenceLayerException
+ {
+ assertFalse(parse("1,2,3,,5,6,7,8,9"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyValue5() throws PersistenceLayerException
+ {
+ assertFalse(parse("1,2,3,4,,6,7,8,9"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyValue6() throws PersistenceLayerException
+ {
+ assertFalse(parse("1,2,3,4,5,,7,8,9"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyValue7() throws PersistenceLayerException
+ {
+ assertFalse(parse("1,2,3,4,5,6,,8,9"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyValue8() throws PersistenceLayerException
+ {
+ assertFalse(parse("1,2,3,4,5,6,7,,9"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidEmptyValue9() throws PersistenceLayerException
+ {
+ assertFalse(parse("1,2,3,4,5,6,7,8,"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testRoundRobinSimple() throws PersistenceLayerException
+ {
+ this.runRoundRobin("1,2,3,4,5,6,7,8,9");
+ }
+
+ @Test
+ public void testRoundRobinComplex() throws PersistenceLayerException
+ {
+ this.runRoundRobin("1,2,3,4*form,5*form,6,7*form,8,9");
+ }
+}
Modified: Trunk/pcgen/code/src/utest/plugin/lsttokens/VFeatLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/VFeatLstTest.java 2008-12-31 18:48:56 UTC (rev 8756)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/VFeatLstTest.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -85,7 +85,7 @@
@Override
public boolean isClearLegal()
{
- return false;
+ return true;
}
static CDOMPrimaryToken<CDOMObject> token = new VFeatLst();
Modified: Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalFormulaTokenTestCase.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalFormulaTokenTestCase.java 2008-12-31 18:48:56 UTC (rev 8756)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalFormulaTokenTestCase.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -19,6 +19,7 @@
import org.junit.Test;
+import pcgen.base.formula.Formula;
import pcgen.cdom.enumeration.FormulaKey;
import pcgen.persistence.PersistenceLayerException;
@@ -30,14 +31,18 @@
public void testValidInputs() throws PersistenceLayerException
{
assertTrue(parse("Variable1"));
- assertEquals("Variable1", primaryProf.get(getFormulaKey()).toString());
+ assertEquals("Variable1", getFormula().toString());
assertTrue(parse("3"));
- assertEquals("3", primaryProf.get(getFormulaKey()).toString());
+ assertEquals("3", getFormula().toString());
assertTrue(parse("3+CL(\"Fighter\""));
- assertEquals("3+CL(\"Fighter\"", primaryProf.get(getFormulaKey())
- .toString());
+ assertEquals("3+CL(\"Fighter\"", getFormula().toString());
}
+ protected Formula getFormula()
+ {
+ return primaryProf.get(getFormulaKey());
+ }
+
public abstract FormulaKey getFormulaKey();
@Test
Modified: Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalListTokenTestCase.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalListTokenTestCase.java 2008-12-31 18:48:56 UTC (rev 8756)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalListTokenTestCase.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -467,7 +467,7 @@
public void testInputInvalidAddsAfterClearNoSideEffect()
throws PersistenceLayerException
{
- if (isClearLegal())
+ if (isClearLegal() && isAllLegal())
{
construct(primaryContext, "TestWP1");
construct(secondaryContext, "TestWP1");
Modified: Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalStringTokenTestCase.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalStringTokenTestCase.java 2008-12-31 18:48:56 UTC (rev 8756)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalStringTokenTestCase.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -27,6 +27,14 @@
{
@Test
+ public void testInvalidInputEmpty() throws PersistenceLayerException
+ {
+ assertFalse(parse(""));
+ assertEquals(null, primaryProf.get(getStringKey()));
+ assertNoSideEffects();
+ }
+
+ @Test
public void testValidInputs() throws PersistenceLayerException
{
assertTrue(parse("Nieder\xF6sterreich"));
Modified: Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalTypeSafeListTestCase.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalTypeSafeListTestCase.java 2008-12-31 18:48:56 UTC (rev 8756)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/testsupport/AbstractGlobalTypeSafeListTestCase.java 2008-12-31 18:49:31 UTC (rev 8757)
@@ -289,7 +289,7 @@
@Test
public void testInputInvalidClearDot() throws PersistenceLayerException
{
- if (isClearDotLegal())
+ if (isClearDotLegal() && requiresPreconstruction())
{
// DoNotConstruct TestWP1
assertTrue(parse(".CLEAR.TestWP1"));
@@ -297,6 +297,8 @@
}
}
+ protected abstract boolean requiresPreconstruction();
+
@Test
public void testInputInvalidAddsAfterClearDotNoSideEffect()
throws PersistenceLayerException
@@ -327,7 +329,7 @@
public void testInputInvalidAddsAfterClearNoSideEffect()
throws PersistenceLayerException
{
- if (isClearLegal())
+ if (isClearLegal() && isAllLegal())
{
assertTrue(parse("TestWP1" + getJoinCharacter() + "TestWP2"));
assertTrue(parseSecondary("TestWP1" + getJoinCharacter()
@@ -337,4 +339,6 @@
assertNoSideEffects();
}
}
+
+ protected abstract boolean isAllLegal();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|