Browse Source

* Start shipping unit tests. The first one checks that converting an

8-bit per channel picture to float32 then back again does not change
    the image.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2621 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 years ago
parent
commit
3d86c2f45a
6 changed files with 79 additions and 1 deletions
  1. +1
    -0
      .gitignore
  2. +1
    -1
      Makefile.am
  3. +1
    -0
      configure.ac
  4. +11
    -0
      test/Makefile.am
  5. BIN
      test/mona.png
  6. +65
    -0
      test/u8tof32tou8.c

+ 1
- 0
.gitignore View File

@@ -12,6 +12,7 @@ pipi/pipi.pc
genethumb/genethumb genethumb/genethumb
examples/blur examples/blur
examples/img2rubik examples/img2rubik
test/u8tof32tou8
stamp-h1 stamp-h1
.auto .auto
.deps .deps


+ 1
- 1
Makefile.am View File

@@ -1,6 +1,6 @@
# $Id$ # $Id$


SUBDIRS = pipi genethumb examples
SUBDIRS = pipi genethumb examples test


EXTRA_DIST = bootstrap common.h EXTRA_DIST = bootstrap common.h
AUTOMAKE_OPTIONS = dist-bzip2 AUTOMAKE_OPTIONS = dist-bzip2


+ 1
- 0
configure.ac View File

@@ -109,6 +109,7 @@ AC_CONFIG_FILES([
pipi/Makefile pipi/Makefile
genethumb/Makefile genethumb/Makefile
examples/Makefile examples/Makefile
test/Makefile
]) ])
AC_CONFIG_FILES([ AC_CONFIG_FILES([
pipi/pipi.pc pipi/pipi.pc


+ 11
- 0
test/Makefile.am View File

@@ -0,0 +1,11 @@

AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/pipi

noinst_PROGRAMS = u8tof32tou8

TESTS = $(noinst_PROGRAMS)

u8tof32tou8_LDADD = ../pipi/libpipi.la

EXTRA_DIST = mona.png


BIN
test/mona.png View File

Before After
Width: 512  |  Height: 512  |  Size: 624 KiB

+ 65
- 0
test/u8tof32tou8.c View File

@@ -0,0 +1,65 @@
/*
* libpipi Proper image processing implementation library
* Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

/*
* loadsave.c: unit test to check that converting an image to float values
* and back to 8-bit integers does not change it.
*/

#include "config.h"
#include "common.h"

#include <stdio.h>
#include <stdlib.h>

#include <pipi.h>

int main(int argc, char *argv[])
{
pipi_image_t *img1, *img2;
pipi_pixels_t *pix1, *pix2;
uint32_t *data1, *data2;
int x, y, ret = EXIT_SUCCESS;

img1 = pipi_load("mona.png");
img2 = pipi_load("mona.png");

pix1 = pipi_getpixels(img1, PIPI_PIXELS_RGBA32);
data1 = (uint32_t *)pix1->pixels;

pipi_getpixels(img2, PIPI_PIXELS_RGBA_F);
pix2 = pipi_getpixels(img2, PIPI_PIXELS_RGBA32);
data2 = (uint32_t *)pix2->pixels;

for(y = 0; y < pix1->h; y++)
{
for(x = 0; x < pix1->w; x++)
{
uint32_t a = data1[y * pix1->w + x];
uint32_t b = data2[y * pix2->w + x];

if(a != b)
{
printf("loadsave: %08x != %08x at (%i,%i)\n", a, b, x, y);
ret = EXIT_FAILURE;
}
}
}

pipi_free(img1);
pipi_free(img2);

return ret;
}


Loading…
Cancel
Save