Skip to content
Snippets Groups Projects
Select Git revision
  • e70fd64e45b75495610cbc0c231d0c82283c2042
  • main default protected
  • master
3 results

ByteGrayColorTest.java

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ByteGrayColorTest.java 772 B
    import org.junit.jupiter.api.Test;
    
    import static org.hamcrest.MatcherAssert.assertThat;
    import static org.hamcrest.Matchers.*;
    
    public class ByteGrayColorTest {
      @Test
      public void testGetLuminosity_whenColorCreatedWithGrayLevel(){
        ByteGrayColor black = new ByteGrayColor(0);
        ByteGrayColor white = new ByteGrayColor(255);
        assertThat(black.getLuminosity(), is(closeTo(0.,.0001)));
        assertThat(white.getLuminosity(), is(closeTo(1.,.0001)));
      }
    
      @Test
      public void testGetLuminosity_whenColorCreatedWithLuminosity(){
        ByteGrayColor color1 = new ByteGrayColor(.25);
        ByteGrayColor color2 = new ByteGrayColor(.75);
        assertThat(color1.getLuminosity(), is(closeTo(.25,.0001)));
        assertThat(color2.getLuminosity(), is(closeTo(.75,.0001)));
      }
    }