<commit_before>package org.smpp.pdu;

import static org.junit.Assert.*;
import static org.powermock.reflect.Whitebox.*;
import static org.smpp.pdu.Matchers.*;

import java.io.UnsupportedEncodingException;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class ByteDataTest {
	private static Class<?> CLAZZ = ByteData.class;

	@Rule
	public ExpectedException thrown = ExpectedException.none();

	@Test
	public void testCheckStringEqualZero() throws Exception {
		checkString("", 0);
	}
	@Test
	public void testCheckStringNonZero() throws Exception {
		checkString(" ", 1);
	}
	@Test
	public void testCheckStringOneZero() throws Exception {
		thrown.expect(stringLengthException(0, 0, 1));
		checkString(" ", 0);
	}

	@Test
	public void testCheckStringUTF16() throws Exception {
		thrown.expect(stringLengthException(0, 1, 4));
		checkString(" ", 1, "UTF-16");
	}
	@Test
	public void testCheckStringInvalidEncoding() throws Exception {
		thrown.expect(UnsupportedEncodingException.class);
		checkString(" ", 1, "UTF-17");
	}

	@Test
	public void testCheckCString() throws Exception {
		thrown.expect(stringLengthException(0, 0, 1));
		invokeMethod(CLAZZ, "checkCString", (String) null, 0, 0);
	}

	@Test
	public void testCheckRange() throws Exception {
		checkRange(0, 0, 0);
		checkRange(0, 10, 100);
	}
	@Test
	public void testCheckRangeBelow() throws Exception {
		thrown.expect(integerOutOfRange(5, 10, 1));
		checkRange(5, 1, 10);
	}
	@Test
	public void testCheckRangeAbove() throws Exception {
		thrown.expect(integerOutOfRange(5, 10, 11));
		checkRange(5, 11, 10);
	}

	@Test
	public void testDecodeUnsignedByte() throws Exception {
		assertEquals(0, decodeUnsigned((byte) 0x00));
		assertEquals(127, decodeUnsigned((byte) 0x7f));
		assertEquals(255, decodeUnsigned((byte) 0xff));
	}
	@Test
	public void testDecodeUnsignedShort() throws Exception {
		assertEquals(0, decodeUnsigned((short) 0));
		assertEquals(32768, decodeUnsigned((short) 32768));
	}
	@Test
	public void testEncodeUnsignedShort() throws Exception {
		assertEquals((byte) 0x00, encodeUnsigned((short) 0));
		assertEquals((byte) 0xff, encodeUnsigned((short) 255));
	}
	@Test
	public void testEncodeUnsignedInt() throws Exception {
		assertEquals((short) 0, encodeUnsigned((int) 0));
		assertEquals((short) 32768, encodeUnsigned((int) 32768));
	}

	// FIXME: plenty more tests to write here

	// maps to ByteData static methods

	private void checkString(String string, int max) throws Exception {
		invokeMethod(CLAZZ, "checkString", string, max);
	}
	private void checkString(String string, int min, int max) throws Exception {
		invokeMethod(CLAZZ, "checkString", string, min, max);
	}
	private void checkString(String string, int max, String encoding) throws Exception {
		invokeMethod(CLAZZ, "checkString", string, max, encoding);
	}
	private void checkString(String string, int min, int max, String encoding) throws Exception {
		invokeMethod(CLAZZ, "checkString", string, min, max, encoding);
	}
	private void checkString(int min, int length, int max) throws Exception {
		invokeMethod(CLAZZ, "checkString", min, length, max);
	}

	private void checkCString(String string, int max) throws Exception {
		invokeMethod(CLAZZ, "checkCString", string, max);
	}
	private void checkCString(String string, int min, int max) throws Exception {
		invokeMethod(CLAZZ, "checkCString", string, min, max);
	}

	private void checkDate(String string) throws Exception {
		invokeMethod(CLAZZ, "checkDate", string);
	}

	private void checkRange(int min, int value, int max) throws Exception {
		invokeMethod(CLAZZ, "checkRange", min, value, max);
	}

	private short decodeUnsigned(byte bite) throws Exception {
		return invokeMethod(CLAZZ, "decodeUnsigned", bite);
	}
	private int decodeUnsigned(short value) throws Exception {
		return invokeMethod(CLAZZ, "decodeUnsigned", value);
	}
	private byte encodeUnsigned(short value) throws Exception {
		return invokeMethod(CLAZZ, "encodeUnsigned", value);
	}
	private short encodeUnsigned(int positive) throws Exception {
		return invokeMethod(CLAZZ, "encodeUnsigned", positive);
	}
}<commit_msg>Fix odd type inference issue on jdk6<commit_after>package org.smpp.pdu;

import static org.junit.Assert.*;
import static org.powermock.reflect.Whitebox.*;
import static org.smpp.pdu.Matchers.*;

import java.io.UnsupportedEncodingException;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.powermock.reflect.Whitebox;

public class ByteDataTest {
	private static Class<?> CLAZZ = ByteData.class;

	@Rule
	public ExpectedException thrown = ExpectedException.none();

	@Test
	public void testCheckStringEqualZero() throws Exception {
		checkString("", 0);
	}
	@Test
	public void testCheckStringNonZero() throws Exception {
		checkString(" ", 1);
	}
	@Test
	public void testCheckStringOneZero() throws Exception {
		thrown.expect(stringLengthException(0, 0, 1));
		checkString(" ", 0);
	}

	@Test
	public void testCheckStringUTF16() throws Exception {
		thrown.expect(stringLengthException(0, 1, 4));
		checkString(" ", 1, "UTF-16");
	}
	@Test
	public void testCheckStringInvalidEncoding() throws Exception {
		thrown.expect(UnsupportedEncodingException.class);
		checkString(" ", 1, "UTF-17");
	}

	@Test
	public void testCheckCString() throws Exception {
		thrown.expect(stringLengthException(0, 0, 1));
		invokeMethod(CLAZZ, "checkCString", (String) null, 0, 0);
	}

	@Test
	public void testCheckRange() throws Exception {
		checkRange(0, 0, 0);
		checkRange(0, 10, 100);
	}
	@Test
	public void testCheckRangeBelow() throws Exception {
		thrown.expect(integerOutOfRange(5, 10, 1));
		checkRange(5, 1, 10);
	}
	@Test
	public void testCheckRangeAbove() throws Exception {
		thrown.expect(integerOutOfRange(5, 10, 11));
		checkRange(5, 11, 10);
	}

	@Test
	public void testDecodeUnsignedByte() throws Exception {
		assertEquals(0, decodeUnsigned((byte) 0x00));
		assertEquals(127, decodeUnsigned((byte) 0x7f));
		assertEquals(255, decodeUnsigned((byte) 0xff));
	}
	@Test
	public void testDecodeUnsignedShort() throws Exception {
		assertEquals(0, decodeUnsigned((short) 0));
		assertEquals(32768, decodeUnsigned((short) 32768));
	}
	@Test
	public void testEncodeUnsignedShort() throws Exception {
		assertEquals((byte) 0x00, encodeUnsigned((short) 0));
		assertEquals((byte) 0xff, encodeUnsigned((short) 255));
	}
	@Test
	public void testEncodeUnsignedInt() throws Exception {
		assertEquals((short) 0, encodeUnsigned((int) 0));
		assertEquals((short) 32768, encodeUnsigned((int) 32768));
	}

	// FIXME: plenty more tests to write here

	// maps to ByteData static methods

	private void checkString(String string, int max) throws Exception {
		invokeMethod(CLAZZ, "checkString", string, max);
	}
	private void checkString(String string, int min, int max) throws Exception {
		invokeMethod(CLAZZ, "checkString", string, min, max);
	}
	private void checkString(String string, int max, String encoding) throws Exception {
		invokeMethod(CLAZZ, "checkString", string, max, encoding);
	}
	private void checkString(String string, int min, int max, String encoding) throws Exception {
		invokeMethod(CLAZZ, "checkString", string, min, max, encoding);
	}
	private void checkString(int min, int length, int max) throws Exception {
		invokeMethod(CLAZZ, "checkString", min, length, max);
	}

	private void checkCString(String string, int max) throws Exception {
		invokeMethod(CLAZZ, "checkCString", string, max);
	}
	private void checkCString(String string, int min, int max) throws Exception {
		invokeMethod(CLAZZ, "checkCString", string, min, max);
	}

	private void checkDate(String string) throws Exception {
		invokeMethod(CLAZZ, "checkDate", string);
	}

	private void checkRange(int min, int value, int max) throws Exception {
		invokeMethod(CLAZZ, "checkRange", min, value, max);
	}

	private short decodeUnsigned(byte bite) throws Exception {
		return Whitebox.<Short> invokeMethod(CLAZZ, "decodeUnsigned", bite);
	}
	private int decodeUnsigned(short value) throws Exception {
		return Whitebox.<Integer> invokeMethod(CLAZZ, "decodeUnsigned", value);
	}
	private byte encodeUnsigned(short value) throws Exception {
		return Whitebox.<Byte> invokeMethod(CLAZZ, "encodeUnsigned", value);
	}
	private short encodeUnsigned(int positive) throws Exception {
		return Whitebox.<Short> invokeMethod(CLAZZ, "encodeUnsigned", positive);
	}
}
{'fraction_non_alphanumeric': 0.1174516550005932, 'fraction_numerical': 0.022422588681931428, 'mean_word_length': 5.627358490566038, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4036334', 'n_tokens_mistral': 2833, 'n_tokens_neox': 2562, 'n_words': 742}