<commit_before>/*
 * Copyright 2013-2016 Netherlands Forensic Institute
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.parsingdata.metal;

import static io.parsingdata.metal.Shorthand.con;
import static io.parsingdata.metal.Shorthand.def;
import static io.parsingdata.metal.Shorthand.eq;
import static io.parsingdata.metal.util.EncodingFactory.enc;
import static io.parsingdata.metal.util.EnvironmentFactory.stream;

import java.io.IOException;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import io.parsingdata.metal.token.Token;

@RunWith(JUnit4.class)
public class SimpleTest {

    private Token buildSimpleToken(final String name, final int size, final int predicate) {
        return def(name, con(size), eq(con(predicate)));
    }

    @Test
    public void correct() throws IOException {
        final Token token = buildSimpleToken("r1", 1, 1);
        Assert.assertTrue(token.parse(stream(1, 2, 3, 4), enc()).succeeded);
    }

    @Test
    public void sizeError() throws IOException {
        final Token token = buildSimpleToken("r1", 2, 1);
        Assert.assertFalse(token.parse(stream(1, 2, 3, 4), enc()).succeeded);
    }

    @Test
    public void predicateError() throws IOException {
        final Token token = buildSimpleToken("r1", 1, 2);
        Assert.assertFalse(token.parse(stream(1, 2, 3, 4), enc()).succeeded);
    }

    @Test
    public void sourceError() throws IOException {
        final Token token = buildSimpleToken("r1", 1, 1);
        Assert.assertFalse(token.parse(stream(2, 2, 2, 2), enc()).succeeded);
    }

}<commit_msg>#59: Formatting cleanup.<commit_after>/*
 * Copyright 2013-2016 Netherlands Forensic Institute
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.parsingdata.metal;

import static org.junit.Assert.assertFalse;

import static io.parsingdata.metal.Shorthand.con;
import static io.parsingdata.metal.Shorthand.def;
import static io.parsingdata.metal.Shorthand.eq;
import static io.parsingdata.metal.util.EncodingFactory.enc;
import static io.parsingdata.metal.util.EnvironmentFactory.stream;

import java.io.IOException;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import io.parsingdata.metal.token.Token;

@RunWith(JUnit4.class)
public class SimpleTest {

    private Token buildSimpleToken(final String name, final int size, final int predicate) {
        return def(name, con(size), eq(con(predicate)));
    }

    @Test
    public void correct() throws IOException {
        final Token token = buildSimpleToken("r1", 1, 1);
        Assert.assertTrue(token.parse(stream(1, 2, 3, 4), enc()).succeeded);
    }

    @Test
    public void sizeError() throws IOException {
        final Token token = buildSimpleToken("r1", 2, 1);
        assertFalse(token.parse(stream(1, 2, 3, 4), enc()).succeeded);
    }

    @Test
    public void predicateError() throws IOException {
        final Token token = buildSimpleToken("r1", 1, 2);
        assertFalse(token.parse(stream(1, 2, 3, 4), enc()).succeeded);
    }

    @Test
    public void sourceError() throws IOException {
        final Token token = buildSimpleToken("r1", 1, 1);
        assertFalse(token.parse(stream(2, 2, 2, 2), enc()).succeeded);
    }

}
{'fraction_non_alphanumeric': 0.10919935765083735, 'fraction_numerical': 0.019729295710025234, 'mean_word_length': 3.7494553376906317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3015328', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1253, 'n_words': 405}