<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 org.apache.bval.constraints;

import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import java.math.BigDecimal;

/**
 * DigitsConstraintValidator Tester.
 *
 * @author <Authors name>
 * @since <pre>02/03/2009</pre>
 * @version 1.0
 */
public class DigitsValidatorTest extends TestCase {
    public DigitsValidatorTest(String name) {
        super(name);
    }

    public void testValidateNumber() {
        DigitsValidatorForNumber validator = new DigitsValidatorForNumber();
        validator.setFractional(4);
        validator.setIntegral(2);
        Assert.assertFalse(validator.isValid(new BigDecimal("100.1234"), null));
        Assert.assertFalse(validator.isValid(new BigDecimal("99.12345"), null));
        Assert.assertTrue(validator.isValid(new BigDecimal("99.1234"), null));
        Assert.assertFalse(validator.isValid(Double.valueOf(100.1234), null));
        Assert.assertFalse(validator.isValid(Double.valueOf(99.12345), null));
        Assert.assertTrue(validator.isValid(Double.valueOf(99.1234), null));
    }

    public void testValidateString() {
        DigitsValidatorForString validator = new DigitsValidatorForString();
        validator.setFractional(4);
        validator.setIntegral(2);
        String val = "100.12345";
        Assert.assertFalse(validator.isValid(val, null));
        val = "99.1234";
        Assert.assertTrue(validator.isValid(val, null));
    }

    public void testValidateNumber2() {
        DigitsValidatorForNumber validator = new DigitsValidatorForNumber();
        validator.setFractional(4);
        validator.setIntegral(2);
        Long val = new Long("100");
        Assert.assertFalse(validator.isValid(val, null));
        val = new Long("99");
        Assert.assertTrue(validator.isValid(val, null));<commit_msg>add breaking test for [BVAL-90]<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 org.apache.bval.constraints;

import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import java.math.BigDecimal;

/**
 * DigitsConstraintValidator Tester.
 *
 * @author <Authors name>
 * @since <pre>02/03/2009</pre>
 * @version 1.0
 */
public class DigitsValidatorTest extends TestCase {
    public DigitsValidatorTest(String name) {
        super(name);
    }

    public void testValidateNumber() {
        DigitsValidatorForNumber validator = new DigitsValidatorForNumber();
        validator.setFractional(4);
        validator.setIntegral(2);
        Assert.assertFalse(validator.isValid(new BigDecimal("100.1234"), null));
        Assert.assertFalse(validator.isValid(new BigDecimal("99.12345"), null));
        Assert.assertTrue(validator.isValid(new BigDecimal("99.1234"), null));
        Assert.assertFalse(validator.isValid(Double.valueOf(100.1234), null));
        Assert.assertFalse(validator.isValid(Double.valueOf(99.12345), null));
        Assert.assertTrue(validator.isValid(Double.valueOf(99.1234), null));
        Assert.assertTrue(validator.isValid(Double.valueOf(99.123400), null));
        Assert.assertTrue(validator.isValid(new BigDecimal("99.123400"), null));
    }

    public void testValidateString() {
        DigitsValidatorForString validator = new DigitsValidatorForString();
        validator.setFractional(4);
        validator.setIntegral(2);
        String val = "100.12345";
        Assert.assertFalse(validator.isValid(val, null));
        val = "99.1234";
        Assert.assertTrue(validator.isValid(val, null));
    }

    public void testValidateNumber2() {
        DigitsValidatorForNumber validator = new DigitsValidatorForNumber();
        validator.setFractional(4);
        validator.setIntegral(2);
        Long val = new Long("100");
        Assert.assertFalse(validator.isValid(val, null));
        val = new Long("99");
        Assert.assertTrue(validator.isValid(val, null));
{'fraction_non_alphanumeric': 0.10530111792282726, 'fraction_numerical': 0.032095203750450774, 'mean_word_length': 3.700847457627119, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '985365', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1522, 'n_words': 418}