package org.oblodiff.util;

import static org.hamcrest.Matchers.is;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 * Tests for {@link CharacterMatcher}.
 */
public class CharacterMatcherTest {

    @Test
    public void isLineFeed_null() {
        assertThat(CharacterMatcher.isLineFeed(null), is(false));
    }

    @Test
    public void isLineFeed_space() {
        assertThat(CharacterMatcher.isLineFeed(' '), is(false));
    }

    @Test
    public void isLineFeed_someChars() {
        assertThat(CharacterMatcher.isLineFeed('a'), is(false));
        assertThat(CharacterMatcher.isLineFeed('F'), is(false));
        assertThat(CharacterMatcher.isLineFeed('X'), is(false));
        assertThat(CharacterMatcher.isLineFeed('?'), is(false));
        assertThat(CharacterMatcher.isLineFeed(';'), is(false));
    }

    @Test
    public void isLineFeed_cr() {
        assertThat(CharacterMatcher.isLineFeed('\r'), is(false));
    }

    @Test
    public void isLineFeed_lf() {
        assertThat(CharacterMatcher.isLineFeed('\n'), is(true));
    }

    @Test
    public void isCariageReturn_null() {
        assertThat(CharacterMatcher.isCariageReturn(null), is(false));
    }

    @Test
    public void isCariageReturn_space() {
        assertThat(CharacterMatcher.isCariageReturn(' '), is(false));
    }

    @Test
    public void isCariageReturn_someChars() {
        assertThat(CharacterMatcher.isCariageReturn('a'), is(false));
        assertThat(CharacterMatcher.isCariageReturn('F'), is(false));
        assertThat(CharacterMatcher.isCariageReturn('X'), is(false));
        assertThat(CharacterMatcher.isCariageReturn('?'), is(false));
        assertThat(CharacterMatcher.isCariageReturn(';'), is(false));
    }

    @Test
    public void isCariageReturn_cr() {
        assertThat(CharacterMatcher.isCariageReturn('\r'), is(true));
    }

    @Test
    public void isCariageReturn_lf() {
        assertThat(CharacterMatcher.isCariageReturn('\n'), is(false));
    }

    @Test
    public void isWhiteSpace_null() {
        assertThat(CharacterMatcher.isWhiteSpace(null), is(false));
    }

    @Test
    public void isWhiteSpace_spaces() {
        assertThat(CharacterMatcher.isWhiteSpace(' '), is(true));
        assertThat(CharacterMatcher.isWhiteSpace('\t'), is(true));
    }

    @Test
    public void isWhiteSpace_nonSpaces() {
        assertThat(CharacterMatcher.isWhiteSpace('.'), is(false));
        assertThat(CharacterMatcher.isWhiteSpace('a'), is(false));
        assertThat(CharacterMatcher.isWhiteSpace('Z'), is(false));
        assertThat(CharacterMatcher.isWhiteSpace('9'), is(false));
    }

    @Test
    public void isNonWhiteSpace_null() {
        assertThat(CharacterMatcher.isNonWhiteSpace(null), is(false));
    }

    @Test
    public void isNonWhiteSpace_spaces() {
        assertThat(CharacterMatcher.isNonWhiteSpace(' '), is(false));
        assertThat(CharacterMatcher.isNonWhiteSpace('\t'), is(false));
    }

    @Test
    public void isNonWhiteSpace_nonSpaces() {
        assertThat(CharacterMatcher.isNonWhiteSpace('.'), is(true));
        assertThat(CharacterMatcher.isNonWhiteSpace('a'), is(true));
        assertThat(CharacterMatcher.isNonWhiteSpace('Z'), is(true));
        assertThat(CharacterMatcher.isNonWhiteSpace('9'), is(true));
    }
}

@@ -32,181 +32,1111 @@
 ort 
-static org.hamcrest.Matchers.is;%0Aimport org.junit.Test;%0Aimport static org.junit.Assert.*;%0A%0A/**%0A * Tests for %7B@link CharacterMatcher%7D.%0A */%0Apublic class CharacterMatcherTest %7B
+java.lang.reflect.Constructor;%0Aimport java.lang.reflect.InvocationTargetException;%0Aimport static org.hamcrest.Matchers.either;%0Aimport static org.hamcrest.Matchers.instanceOf;%0Aimport static org.hamcrest.Matchers.is;%0Aimport org.junit.Test;%0Aimport static org.junit.Assert.*;%0Aimport org.junit.Rule;%0Aimport org.junit.rules.ExpectedException;%0A%0A/**%0A * Tests for %7B@link CharacterMatcher%7D.%0A *%0A * @author Sven Strittmatter &lt;weltraumschaf@googlemail.com&gt;%0A */%0Apublic class CharacterMatcherTest %7B%0A%0A    @Rule%0A    //CHECKSTYLE:OFF%0A    public final ExpectedException thrown = ExpectedException.none();%0A    //CHECKSTYLE:ON%0A%0A    @Test%0A    public void invokeConstructorByReflectionThrowsException() throws Exception %7B%0A        assertThat(CharacterMatcher.class.getDeclaredConstructors().length, is(1));%0A%0A        final Constructor%3CCharacterMatcher%3E ctor = CharacterMatcher.class.getDeclaredConstructor();%0A        ctor.setAccessible(true);%0A%0A        thrown.expect(either(instanceOf(UnsupportedOperationException.class))%0A                .or(instanceOf(InvocationTargetException.class)));%0A        ctor.newInstance();%0A    %7D
 %0A%0A  

Test that constructor is not invokable by reflection.