<commit_before>package org.bricolages.streaming.filter;

import org.junit.Test;
import static org.junit.Assert.*;
import lombok.*;

public class FloatOpTest {
    OpBuilder builder = new OpBuilder();

    @Test
    public void apply() throws Exception {
        val def = new OperatorDefinition("float", "schema.table", "b", "{}");
        val op = (FloatOp) builder.build(def);
        {
            val rec = Record.parse("{\"a\":1,\"b\":1.5,\"c\":3}");
            val out = op.apply(rec);
            assertEquals("{\"a\":1,\"b\":1.5,\"c\":3}", out.serialize());
        }
        {
            val rec = Record.parse("{\"a\":1,\"b\":\"1.5\",\"c\":3}");
            val out = op.apply(rec);
            assertEquals("{\"a\":1,\"b\":1.5,\"c\":3}", out.serialize());
        }
        {
            val rec = Record.parse("{\"a\":1,\"b\":\"1.234e2\",\"c\":3}");
            val out = op.apply(rec);
            assertEquals("{\"a\":1,\"b\":123.4,\"c\":3}", out.serialize());
        }
    }

    @Test
    public void apply_too_large_value() throws Exception {
        val f = new FloatOp(null);
        assertEquals(null, f.applyValue(Double.MAX_VALUE, null));
    }

    @Test
    public void apply_too_small_value() throws Exception {
        val f = new FloatOp(null);
        assertEquals(null, f.applyValue(Double.MIN_VALUE, null));
    }
<commit_msg>Tweak FloatOp test<commit_after>package org.bricolages.streaming.filter;

import org.junit.Test;
import static org.junit.Assert.*;
import lombok.*;

public class FloatOpTest {
    OpBuilder builder = new OpBuilder();

    @Test
    public void apply() throws Exception {
        val def = new OperatorDefinition("float", "schema.table", "n", "{}");
        val op = (FloatOp) builder.build(def);
        {
            val rec = Record.parse("{\"n\":1.5}");
            val out = op.apply(rec);
            assertEquals("{\"n\":1.5}", out.serialize());
        }
        {
            val rec = Record.parse("{\"n\":\"1.5\"}");
            val out = op.apply(rec);
            assertEquals("{\"n\":1.5}", out.serialize());
        }
        {
            val rec = Record.parse("{\"n\":\"1.234e2\"}");
            val out = op.apply(rec);
            assertEquals("{\"n\":123.4}", out.serialize());
        }
        {
            val rec = Record.parse("{\"n\":1.234e2}");
            val out = op.apply(rec);
            assertEquals("{\"n\":123.4}", out.serialize());
        }
    }

    @Test
    public void apply_too_large_value() throws Exception {
        val f = new FloatOp(null);
        assertEquals(null, f.applyValue(Double.MAX_VALUE, null));
    }

    @Test
    public void apply_too_small_value() throws Exception {
        val f = new FloatOp(null);
        assertEquals(null, f.applyValue(Double.MIN_VALUE, null));
    }

{'fraction_non_alphanumeric': 0.1925687745623437, 'fraction_numerical': 0.019649874955341193, 'mean_word_length': 2.0973451327433628, 'pattern_counts': {'":': 26, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2368791', 'n_tokens_mistral': 894, 'n_tokens_neox': 875, 'n_words': 174}