Skip to content

Commit cc518ba

Browse files
isazfranzEbaron96smarasca5
authored
P Font Tests (#1511)
* this is just a test * more test changes * Setup The Test File, Wrote up what should be tested first by chunks. * Added first test! added tons of comments. * This is one test, for the PFont name getter * tests for psname getter and size getter for PFont * fixed psname test, works on mac and windows now * Added correct and working test on getName * Tests for getNative --------- Co-authored-by: Elijah Baron <elijahjbaron96@gmail.com> Co-authored-by: smarasca5 <smarasca5@gmail.com>
1 parent 4b0468e commit cc518ba

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package processing.core;
2+
3+
import java.awt.Font; //Javas built in font class
4+
import org.junit.Test; //Using Junit4 test implementation
5+
import static org.junit.Assert.assertEquals; //To compare expected vs actual values
6+
7+
public class PFontTest {
8+
9+
@Test
10+
public void testGetFontNameCorrectly() {
11+
Font trueFont = new Font("Name", Font.PLAIN, 16);
12+
PFont font = new PFont(trueFont, true, null);
13+
assertEquals("Name", font.getName());
14+
}
15+
16+
17+
@Test
18+
public void testGetCorrectPSName() {
19+
Font awtFont = new Font("Dialog", Font.PLAIN, 16); //Truth, what PFont size should be
20+
PFont font = new PFont(awtFont, true, null);
21+
assertEquals(awtFont.getPSName(), font.getPostScriptName()); //test, expecting
22+
}
23+
24+
@Test
25+
public void testGetCorrectSize() {
26+
Font awtFont = new Font("Dialog", Font.PLAIN, 16); //Truth, what PFont size should be
27+
PFont font = new PFont(awtFont, true, null);
28+
assertEquals(awtFont.getSize(), font.getSize()); //test, expecting
29+
}
30+
31+
@Test
32+
public void testGetNative() {
33+
Font awtFont = new Font("Dialog", Font.PLAIN, 16);
34+
PFont font = new PFont(awtFont, true, null);
35+
assertEquals(awtFont, font.getNative());
36+
}
37+
}

0 commit comments

Comments
 (0)