<commit_before>package net.coobird.thumbnailator.filters;

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

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

import net.coobird.thumbnailator.test.BufferedImageComparer;
import net.coobird.thumbnailator.util.BufferedImages;

import org.junit.Test;

public class FlipTest {
	
	private static int SIZE = 160;
	
	@Test
	public void flipHorizontal() throws Exception {
		// given
		BufferedImage img = ImageIO.read(new File("test-resources/Exif/original.png"));
		
		// when
		BufferedImage result = Flip.HORIZONTAL.apply(img);
		
		// then
		assertEquals(Color.black.getRGB(), result.getRGB(0, 0));
		assertEquals(Color.black.getRGB(), result.getRGB(0, SIZE / 2 - 1));
		assertEquals(Color.white.getRGB(), result.getRGB(0, SIZE - 1));
		assertEquals(Color.black.getRGB(), result.getRGB(SIZE - 1, 0));
		assertEquals(Color.black.getRGB(), result.getRGB(SIZE - 1, SIZE / 2 - 1));
		assertEquals(Color.black.getRGB(), result.getRGB(SIZE - 1, SIZE - 1));
	}
	
	@Test
	public void flipVertical() throws Exception {
		// given
		BufferedImage img = ImageIO.read(new File("test-resources/Exif/original.png"));
		
		// when
		BufferedImage result = Flip.VERTICAL.apply(img);
		
		// then
		assertEquals(Color.black.getRGB(), result.getRGB(0, 0));
		assertEquals(Color.black.getRGB(), result.getRGB(0, SIZE / 2 - 1));
		assertEquals(Color.black.getRGB(), result.getRGB(0, SIZE - 1));
		assertEquals(Color.white.getRGB(), result.getRGB(SIZE - 1, 0));
		assertEquals(Color.black.getRGB(), result.getRGB(SIZE - 1, SIZE / 2 - 1));
		assertEquals(Color.black.getRGB(), result.getRGB(SIZE - 1, SIZE - 1));
	}
	
	/**
	 * Checks that the input image contents are not altered, when using the
	 * {@link Flip#HORIZONTAL}.
	 */
	@Test
	public void inputContentsAreNotAltered_UsingFlipHorizontal() 
	{
		// given
		BufferedImage originalImage = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);<commit_msg>Changed the unit tests to use the new `BufferedImageAssert` assertion method.<commit_after>package net.coobird.thumbnailator.filters;

import static org.junit.Assert.assertTrue;

import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

import net.coobird.thumbnailator.test.BufferedImageAssert;
import net.coobird.thumbnailator.test.BufferedImageComparer;
import net.coobird.thumbnailator.util.BufferedImages;

import org.junit.Test;

public class FlipTest {
	
	@Test
	public void flipHorizontal() throws Exception {
		// given
		BufferedImage img = ImageIO.read(new File("test-resources/Exif/original.png"));
		
		// when
		BufferedImage result = Flip.HORIZONTAL.apply(img);
		
		// then
		BufferedImageAssert.assertMatches(
				result, 
				new float[] {
						1, 1, 1,
						1, 1, 1,
						0, 0, 1,
				}
		);
	}
	
	@Test
	public void flipVertical() throws Exception {
		// given
		BufferedImage img = ImageIO.read(new File("test-resources/Exif/original.png"));
		
		// when
		BufferedImage result = Flip.VERTICAL.apply(img);
		
		// then
		BufferedImageAssert.assertMatches(
				result, 
				new float[] {
						1, 0, 0,
						1, 1, 1,
						1, 1, 1,
				}
		);
	}
	
	/**
	 * Checks that the input image contents are not altered, when using the
	 * {@link Flip#HORIZONTAL}.
	 */
	@Test
	public void inputContentsAreNotAltered_UsingFlipHorizontal() 
	{
		// given
		BufferedImage originalImage = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
{'fraction_non_alphanumeric': 0.12942509204191446, 'fraction_numerical': 0.017275559331634098, 'mean_word_length': 3.8583218707015132, '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': '7386752', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1158, 'n_words': 255}