MCPcopy Create free account
hub / github.com/PCGen/pcgen / testRandomize

Method testRandomize

code/src/test/pcgen/core/BioSetTest.java:90–133  ·  view source on GitHub ↗

Verify that the randomize function in BioSet is functioning properly.

()

Source from the content-addressed store, hash-verified

88 * is functioning properly.
89 */
90 @Test
91 public void testRandomize()
92 {
93 final int[] BASE_AGE = {15, 35, 53, 70};
94 final int[] MAX_AGE = {34, 52, 69, 110};
95
96 final BioSet currBioSet = SettingsHandler.getGameAsProperty().get().getBioSet();
97 final PlayerCharacter pc = getCharacter();
98 final Race human = new Race();
99 human.setName("NAME_Human");
100 human.put(StringKey.KEY_NAME, "Human");
101 pc.setRace(human);
102 for (int ageCat = 0; ageCat < MAX_AGE.length; ageCat++)
103 {
104 currBioSet.randomize("AGECAT" + ageCat, pc);
105 final int age = (Integer) getAge(pc);
106 //System.out.println("Age for cat " + ageCat + " is " + age + ".");
107 assertTrue(
108 (age >= BASE_AGE[ageCat] && age <= MAX_AGE[ageCat]), "Generated age " + age + " is not between "
109 + BASE_AGE[ageCat] + " and " + MAX_AGE[ageCat]);
110 }
111 LocaleDependentTestCase.before(Locale.US);
112 currBioSet.randomize("AGE.HT.WT.EYES.HAIR.SKIN", pc);
113 LocaleDependentTestCase.after();
114 Integer height = HeightCompat.getCurrentHeight(pc.getCharID());
115 assertTrue((height >= 58 && height <= 78),
116 "Generated height " + height + " is not in required range.");
117 assertTrue((pc.getDisplay().getWeight() >= 120 && pc
118 .getDisplay().getWeight() <= 280), "Generated weight " + pc.getDisplay().getWeight()
119 + " is not in required range.");
120 assertEquals("Blue", pc.getSafeStringFor(PCStringKey.EYECOLOR), "Generated eye colour " + pc.getSafeStringFor(PCStringKey.EYECOLOR)
121 + " is not valid.");
122 assertTrue(
123 ("Blond".equals(HairColorCompat.getCurrentHairColor(pc.getCharID()))
124 || "Brown".equals(
125 HairColorCompat.getCurrentHairColor(pc.getCharID()))),
126 "Generated hair colour "
127 + HairColorCompat.getCurrentHairColor(pc.getCharID())
128 + " is not valid.");
129 String skinColor = (String) ChannelUtilities
130 .readControlledChannel(pc.getCharID(), CControl.SKINCOLORINPUT);
131 assertTrue(("Pasty".equals(skinColor) || "Tanned".equals(skinColor)),
132 "Generated skin colour " + skinColor + " is not valid.");
133 }
134
135 /**
136 * Test the age set

Callers

nothing calls this directly

Calls 15

getGameAsPropertyMethod · 0.95
setRaceMethod · 0.95
randomizeMethod · 0.95
getAgeMethod · 0.95
beforeMethod · 0.95
afterMethod · 0.95
getCurrentHeightMethod · 0.95
getCharIDMethod · 0.95
getDisplayMethod · 0.95
getSafeStringForMethod · 0.95
getCurrentHairColorMethod · 0.95
readControlledChannelMethod · 0.95

Tested by

no test coverage detected