<commit_before>package net.bolbat.utils.lang;

import java.util.Calendar;

import org.junit.Assert;
import org.junit.Test;

/**
 * {@link TimeUtilsTest} test.
 *
 * @author <NAME>
 */

public class TimeUtilsTest {

	@Test
	public void generalTest() {

		// check TimeUnit values

		Assert.assertEquals("Should be equal.", Calendar.YEAR, TimeUtils.TimeUnit.YEAR.getMappedCalendarField());
		Assert.assertEquals("Should be equal.", Calendar.MONTH, TimeUtils.TimeUnit.MONTH.getMappedCalendarField());
		Assert.assertEquals("Should be equal.", Calendar.DAY_OF_MONTH, TimeUtils.TimeUnit.DAY.getMappedCalendarField());
		Assert.assertEquals("Should be equal.", Calendar.HOUR_OF_DAY, TimeUtils.TimeUnit.HOUR.getMappedCalendarField());
		Assert.assertEquals("Should be equal.", Calendar.MINUTE, TimeUtils.TimeUnit.MINUTE.getMappedCalendarField());
		Assert.assertEquals("Should be equal.", Calendar.SECOND, TimeUtils.TimeUnit.SECOND.getMappedCalendarField());

		// check rounding

		checkRound(TimeUtils.TimeUnit.SECOND, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.SECOND, TimeUtils.Rounding.UP);

		checkRound(TimeUtils.TimeUnit.MINUTE, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.MINUTE, TimeUtils.Rounding.UP);

		checkRound(TimeUtils.TimeUnit.HOUR, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.HOUR, TimeUtils.Rounding.UP);

		checkRound(TimeUtils.TimeUnit.DAY, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.DAY, TimeUtils.Rounding.UP);

		checkRound(TimeUtils.TimeUnit.MONTH, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.MONTH, TimeUtils.Rounding.UP);

		checkRound(TimeUtils.TimeUnit.YEAR, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.YEAR, TimeUtils.Rounding.UP);

		// check 'from now'

		checkFromNow(1, TimeUtils.TimeUnit.YEAR);
		checkFromNow(-1, TimeUtils.TimeUnit.YEAR);

		checkFromNow(1, TimeUtils.TimeUnit.MONTH);
		checkFromNow(-1, TimeUtils.TimeUnit.MONTH);

		checkFromNow(1, TimeUtils.TimeUnit.DAY);
		checkFromNow(-1, TimeUtils.TimeUnit.DAY);

		checkFromNow(1, TimeUtils.TimeUnit.HOUR);
		checkFromNow(-1, TimeUtils.TimeUnit.HOUR);

		checkFromNow(1, TimeUtils.TimeUnit.MINUTE);
		checkFromNow(-1, TimeUtils.TimeUnit.MINUTE);

		checkFromNow(1, TimeUtils.TimeUnit.SECOND);
		checkFromNow(-1, TimeUtils.TimeUnit.SECOND);

		// check 'from now' with no rounding param

		int fromNow = 1;
		TimeUtils.TimeUnit timeUnit = TimeUtils.TimeUnit.DAY;<commit_msg>BBUTILS-9 cleanup test<commit_after>package net.bolbat.utils.lang;

import java.util.Calendar;

import org.junit.Assert;
import org.junit.Test;

/**
 * {@link TimeUtilsTest} test.
 *
 * @author <NAME>
 */
public class TimeUtilsTest {

	@Test
	public void generalTest() {
		// check TimeUnit values
		Assert.assertEquals("Should be equal.", Calendar.YEAR, TimeUtils.TimeUnit.YEAR.getMappedCalendarField());
		Assert.assertEquals("Should be equal.", Calendar.MONTH, TimeUtils.TimeUnit.MONTH.getMappedCalendarField());
		Assert.assertEquals("Should be equal.", Calendar.DAY_OF_MONTH, TimeUtils.TimeUnit.DAY.getMappedCalendarField());
		Assert.assertEquals("Should be equal.", Calendar.HOUR_OF_DAY, TimeUtils.TimeUnit.HOUR.getMappedCalendarField());
		Assert.assertEquals("Should be equal.", Calendar.MINUTE, TimeUtils.TimeUnit.MINUTE.getMappedCalendarField());
		Assert.assertEquals("Should be equal.", Calendar.SECOND, TimeUtils.TimeUnit.SECOND.getMappedCalendarField());

		// check rounding
		checkRound(TimeUtils.TimeUnit.SECOND, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.SECOND, TimeUtils.Rounding.UP);

		checkRound(TimeUtils.TimeUnit.MINUTE, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.MINUTE, TimeUtils.Rounding.UP);

		checkRound(TimeUtils.TimeUnit.HOUR, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.HOUR, TimeUtils.Rounding.UP);

		checkRound(TimeUtils.TimeUnit.DAY, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.DAY, TimeUtils.Rounding.UP);

		checkRound(TimeUtils.TimeUnit.MONTH, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.MONTH, TimeUtils.Rounding.UP);

		checkRound(TimeUtils.TimeUnit.YEAR, TimeUtils.Rounding.DOWN);
		checkRound(TimeUtils.TimeUnit.YEAR, TimeUtils.Rounding.UP);

		// check 'from now'
		checkFromNow(1, TimeUtils.TimeUnit.YEAR);
		checkFromNow(-1, TimeUtils.TimeUnit.YEAR);

		checkFromNow(1, TimeUtils.TimeUnit.MONTH);
		checkFromNow(-1, TimeUtils.TimeUnit.MONTH);

		checkFromNow(1, TimeUtils.TimeUnit.DAY);
		checkFromNow(-1, TimeUtils.TimeUnit.DAY);

		checkFromNow(1, TimeUtils.TimeUnit.HOUR);
		checkFromNow(-1, TimeUtils.TimeUnit.HOUR);

		checkFromNow(1, TimeUtils.TimeUnit.MINUTE);
		checkFromNow(-1, TimeUtils.TimeUnit.MINUTE);

		checkFromNow(1, TimeUtils.TimeUnit.SECOND);
		checkFromNow(-1, TimeUtils.TimeUnit.SECOND);

		// check 'from now' with no rounding param
		int fromNow = 1;
		TimeUtils.TimeUnit timeUnit = TimeUtils.TimeUnit.DAY;
{'fraction_non_alphanumeric': 0.13048805391055748, 'fraction_numerical': 0.005513579742699612, 'mean_word_length': 5.654891304347826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2762555', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1611, 'n_words': 239}