<commit_before>package de.tobiasroeser.lambdatest;

import java.lang.reflect.Array;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import de.tobiasroeser.lambdatest.internal.LoggerFactory;
import de.tobiasroeser.lambdatest.internal.Util;

/**
 * Holds various assert-methods.
 * 
 * @see Expect
 *
 */
public class Assert {

	private static final List<Class<?>> LONG_TYPES = Arrays.asList(Byte.class, Short.class, Integer.class, Long.class);
	private static final List<Class<?>> DOUBLE_TYPES = Arrays.asList(Float.class, Double.class);

	/* package */ static void fail(final String userGivenMessageOrNull, final String msg, final Object... args) {
		final String formatted;
		if (args == null || args.length == 0) {
			formatted = msg;
		} else {
			final Object[] niceArgs = new Object[args.length];
			for (int i = 0; i < args.length; ++i) {
				final Object arg = args[i];
				final Class<? extends Object> argClass = arg.getClass();
				if (arg != null && argClass.isArray()) {
					List<Object> argObjects = new LinkedList<Object>();
					if (argClass.equals(boolean[].class)) {
						for (final boolean b : (boolean[]) arg) {
							argObjects.add(Boolean.valueOf(b).toString());
						}
					} else if (argClass.equals(byte[].class)) {
						for (final byte b : (byte[]) arg) {
							argObjects.add(Byte.valueOf(b).toString());
						}
					} else if (argClass.equals(short[].class)) {
						for (final short b : (short[]) arg) {
							argObjects.add(Short.valueOf(b).toString());
						}
					} else if (argClass.equals(int[].class)) {
						for (final int b : (int[]) arg) {
							argObjects.add(Integer.valueOf(b).toString());
						}
					} else if (argClass.equals(long[].class)) {
						for (final long b : (long[]) arg) {
							argObjects.add(Long.valueOf(b).toString());
						}
					} else if (argClass.equals(float[].class)) {
						for (final float b : (float[]) arg) {
							argObjects.add(Float.valueOf(b).toString());
						}
					} else if (argClass.equals(double[].class)) {
						for (final double b : (double[]) arg) {<commit_msg>Fixed potential NPE in Assert message formatter<commit_after>package de.tobiasroeser.lambdatest;

import java.lang.reflect.Array;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import de.tobiasroeser.lambdatest.internal.LoggerFactory;
import de.tobiasroeser.lambdatest.internal.Util;

/**
 * Holds various assert-methods.
 * 
 * @see Expect
 *
 */
public class Assert {

	private static final List<Class<?>> LONG_TYPES = Arrays.asList(Byte.class, Short.class, Integer.class, Long.class);
	private static final List<Class<?>> DOUBLE_TYPES = Arrays.asList(Float.class, Double.class);

	/* package */ static void fail(final String userGivenMessageOrNull, final String msg, final Object... args) {
		final String formatted;
		if (args == null || args.length == 0) {
			formatted = msg;
		} else {
			final Object[] niceArgs = new Object[args.length];
			for (int i = 0; i < args.length; ++i) {
				final Object arg = args[i];
				if (arg != null && arg.getClass().isArray()) {
					final Class<? extends Object> argClass = arg.getClass();
					List<Object> argObjects = new LinkedList<Object>();
					if (argClass.equals(boolean[].class)) {
						for (final boolean b : (boolean[]) arg) {
							argObjects.add(Boolean.valueOf(b).toString());
						}
					} else if (argClass.equals(byte[].class)) {
						for (final byte b : (byte[]) arg) {
							argObjects.add(Byte.valueOf(b).toString());
						}
					} else if (argClass.equals(short[].class)) {
						for (final short b : (short[]) arg) {
							argObjects.add(Short.valueOf(b).toString());
						}
					} else if (argClass.equals(int[].class)) {
						for (final int b : (int[]) arg) {
							argObjects.add(Integer.valueOf(b).toString());
						}
					} else if (argClass.equals(long[].class)) {
						for (final long b : (long[]) arg) {
							argObjects.add(Long.valueOf(b).toString());
						}
					} else if (argClass.equals(float[].class)) {
						for (final float b : (float[]) arg) {
							argObjects.add(Float.valueOf(b).toString());
						}
					} else if (argClass.equals(double[].class)) {
						for (final double b : (double[]) arg) {
{'fraction_non_alphanumeric': 0.15700644015101045, 'fraction_numerical': 0.0008882966910948257, 'mean_word_length': 3.343297974927676, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, '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': '5995567', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1438, 'n_words': 344}