Skip to content
37 changes: 37 additions & 0 deletions core/test/processing/core/PFontTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package processing.core;

import java.awt.Font; //Javas built in font class
import org.junit.Test; //Using Junit4 test implementation
import static org.junit.Assert.assertEquals; //To compare expected vs actual values

public class PFontTest {

@Test
public void testGetFontNameCorrectly() {
Font trueFont = new Font("Name", Font.PLAIN, 16);
PFont font = new PFont(trueFont, true, null);
assertEquals("Name", font.getName());
}


@Test
public void testGetCorrectPSName() {
Font awtFont = new Font("Dialog", Font.PLAIN, 16); //Truth, what PFont size should be
PFont font = new PFont(awtFont, true, null);
assertEquals(awtFont.getPSName(), font.getPostScriptName()); //test, expecting
}

@Test
public void testGetCorrectSize() {
Font awtFont = new Font("Dialog", Font.PLAIN, 16); //Truth, what PFont size should be
PFont font = new PFont(awtFont, true, null);
assertEquals(awtFont.getSize(), font.getSize()); //test, expecting
}

@Test
public void testGetNative() {
Font awtFont = new Font("Dialog", Font.PLAIN, 16);
PFont font = new PFont(awtFont, true, null);
assertEquals(awtFont, font.getNative());
}
}