<commit_before>package st.extreme.math;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.math.BigInteger;

import org.junit.Test;

public class BigFractionConstructionTest {

  private static final BigInteger MINUS_THREE = new BigInteger("-3");
  private static final BigInteger MINUS_TWO = new BigInteger("-2");
  private static final BigInteger ZERO = new BigInteger("0");
  private static final BigInteger ONE = new BigInteger("1");
  private static final BigInteger TWO = new BigInteger("2");
  private static final BigInteger THREE = new BigInteger("3");

  @Test
  public void testStringConstructor_IllegalCharacter() {
    try {
      new BigFraction(".", "4");
      fail("NumberFormatException expected");
    } catch (NumberFormatException nfe) {
      // ok
    }
    try {
      new BigFraction("4", ".");
      fail("NumberFormatException expected");
    } catch (NumberFormatException nfe) {
      // ok
    }
  }

  @Test
  public void testStringConstructor_divisionByZero() {
    try {
      new BigFraction("1", "0");
      fail("ArithmeticException expected");
    } catch (ArithmeticException ae) {
      assertTrue(ae.getMessage().contains("division by zero"));
    }
  }

  @Test
  public void testStringConstructor_Sign() {
    BigFraction bf = new BigFraction("2", "-3");
    // expect the sign in the numerator
    assertEquals(MINUS_TWO, bf.getNumerator());
    assertEquals(THREE, bf.getDenominator());
  }

  @Test
  public void testStringConstructor() {
    BigFraction bf = new BigFraction("2", "3");
    assertEquals(TWO, bf.getNumerator());
    assertEquals(THREE, bf.getDenominator());
  }

  @Test
  public void testBigIntegerConstructor() {
    BigFraction bf = new BigFraction(TWO, THREE);
    assertEquals(TWO, bf.getNumerator());
    assertEquals(THREE, bf.getDenominator());
  }

  @Test
  public void testBigIntegerConstructor_divisionByZero() {
    try {
      new BigFraction(ONE, ZERO);
      fail("ArithmeticException expected");
    } catch (ArithmeticException ae) {
      assertTrue(ae.getMessage().contains("division by zero"));
    }
  }

  @Test
  public void testBigIntegerConstructor_Sign() {
    BigFraction bf = new BigFraction(TWO, MINUS_THREE);
    // expect the sign in the numerator
    assertEquals(MINUS_TWO, bf.getNumerator());
    assertEquals(THREE, bf.getDenominator());
  }

}<commit_msg>test both numerator and denominator negative<commit_after>package st.extreme.math;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.math.BigInteger;

import org.junit.Test;

public class BigFractionConstructionTest {

  private static final BigInteger MINUS_THREE = new BigInteger("-3");
  private static final BigInteger MINUS_TWO = new BigInteger("-2");
  private static final BigInteger ZERO = new BigInteger("0");
  private static final BigInteger ONE = new BigInteger("1");
  private static final BigInteger TWO = new BigInteger("2");
  private static final BigInteger THREE = new BigInteger("3");

  @Test
  public void testStringConstructor_IllegalCharacter() {
    try {
      new BigFraction(".", "4");
      fail("NumberFormatException expected");
    } catch (NumberFormatException nfe) {
      // ok
    }
    try {
      new BigFraction("4", ".");
      fail("NumberFormatException expected");
    } catch (NumberFormatException nfe) {
      // ok
    }
  }

  @Test
  public void testStringConstructor_divisionByZero() {
    try {
      new BigFraction("1", "0");
      fail("ArithmeticException expected");
    } catch (ArithmeticException ae) {
      assertTrue(ae.getMessage().contains("division by zero"));
    }
  }

  @Test
  public void testStringConstructor_Sign() {
    BigFraction bf;

    bf = new BigFraction("2", "-3");
    // expect the sign in the numerator
    assertEquals(MINUS_TWO, bf.getNumerator());
    assertEquals(THREE, bf.getDenominator());
    assertEquals(-1, bf.signum());

    bf = new BigFraction("-2", "-3");
    assertEquals(TWO, bf.getNumerator());
    assertEquals(THREE, bf.getDenominator());
    assertEquals(1, bf.signum());
  }

  @Test
  public void testStringConstructor() {
    BigFraction bf = new BigFraction("2", "3");
    assertEquals(TWO, bf.getNumerator());
    assertEquals(THREE, bf.getDenominator());
  }

  @Test
  public void testBigIntegerConstructor() {
    BigFraction bf = new BigFraction(TWO, THREE);
    assertEquals(TWO, bf.getNumerator());
    assertEquals(THREE, bf.getDenominator());
  }

  @Test
  public void testBigIntegerConstructor_divisionByZero() {
    try {
      new BigFraction(ONE, ZERO);
      fail("ArithmeticException expected");
    } catch (ArithmeticException ae) {
      assertTrue(ae.getMessage().contains("division by zero"));
    }
  }

  @Test
  public void testBigIntegerConstructor_Sign() {
    BigFraction bf;

    bf = new BigFraction(TWO, MINUS_THREE);
    // expect the sign in the numerator
    assertEquals(MINUS_TWO, bf.getNumerator());
    assertEquals(THREE, bf.getDenominator());
    assertEquals(-1, bf.signum());

    bf = new BigFraction(MINUS_TWO, MINUS_THREE);
    assertEquals(TWO, bf.getNumerator());
    assertEquals(THREE, bf.getDenominator());
    assertEquals(1, bf.signum());
  }

}
{'fraction_non_alphanumeric': 0.12216601086752857, 'fraction_numerical': 0.006370620198613453, 'mean_word_length': 3.791741472172352, 'pattern_counts': {'":': 0, '<': 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': '6345000', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1617, 'n_words': 389}