Kaynağa Gözat

test: add simple unit tests for image loading.

legacy
Sam Hocevar sam 13 yıl önce
ebeveyn
işleme
48bde6fa94
3 değiştirilmiş dosya ile 54 ekleme ve 1 silme
  1. +4
    -1
      test/Makefile.am
  2. BIN
      test/data/gradient.png
  3. +50
    -0
      test/unit/image.cpp

+ 4
- 1
test/Makefile.am Dosyayı Görüntüle

@@ -14,12 +14,15 @@ CLEANFILES = $(noinst_PROGRAMS:%$(EXEEXT)=%.self) \
$(noinst_PROGRAMS:%$(EXEEXT)=%.elf) \
$(noinst_PROGRAMS:%$(EXEEXT)=%.exe)

EXTRA_DIST = data/gradient.png

noinst_PROGRAMS = quad sandbox benchsuite testsuite

TESTS = testsuite

testsuite_SOURCES = testsuite.cpp \
unit/matrix.cpp unit/half.cpp unit/trig.cpp unit/build.cpp unit/real.cpp
unit/matrix.cpp unit/half.cpp unit/trig.cpp unit/build.cpp \
unit/real.cpp unit/image.cpp
testsuite_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@
testsuite_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@
testsuite_DEPENDENCIES = $(top_builddir)/src/liblol.a


BIN
test/data/gradient.png Dosyayı Görüntüle

Önce Sonra
Genişlik: 256  |  Yükseklik: 16  |  Boyut: 196 B

+ 50
- 0
test/unit/image.cpp Dosyayı Görüntüle

@@ -0,0 +1,50 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
// This program is free software; 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/projects/COPYING.WTFPL for more details.
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cmath>

#include "core.h"
#include "lol/unit.h"

namespace lol
{

LOLUNIT_FIXTURE(ImageTest)
{
LOLUNIT_TEST(OpenImage)
{
Image *image = new Image("data/gradient.png");
LOLUNIT_ASSERT(image);

ivec2 size = image->GetSize();
LOLUNIT_ASSERT_EQUAL(size.x, 256);
LOLUNIT_ASSERT_EQUAL(size.y, 16);

uint8_t *data = (uint8_t *)image->GetData();
LOLUNIT_ASSERT(data);

LOLUNIT_ASSERT_EQUAL((int)data[0], 0x00);
LOLUNIT_ASSERT_EQUAL((int)data[1], 0x00);
LOLUNIT_ASSERT_EQUAL((int)data[2], 0x00);

LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 0], 0xff);
LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 1], 0xff);
LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 2], 0xff);

delete image;
}
};

} /* namespace lol */


Yükleniyor…
İptal
Kaydet