source: trunk/test/unit/image.cpp @ 982

Last change on this file since 982 was 978, checked in by sam, 11 years ago

test: add simple unit tests for image loading.

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cmath>
16
17#include "core.h"
18#include "lol/unit.h"
19
20namespace lol
21{
22
23LOLUNIT_FIXTURE(ImageTest)
24{
25    LOLUNIT_TEST(OpenImage)
26    {
27        Image *image = new Image("data/gradient.png");
28        LOLUNIT_ASSERT(image);
29
30        ivec2 size = image->GetSize();
31        LOLUNIT_ASSERT_EQUAL(size.x, 256);
32        LOLUNIT_ASSERT_EQUAL(size.y, 16);
33
34        uint8_t *data = (uint8_t *)image->GetData();
35        LOLUNIT_ASSERT(data);
36
37        LOLUNIT_ASSERT_EQUAL((int)data[0], 0x00);
38        LOLUNIT_ASSERT_EQUAL((int)data[1], 0x00);
39        LOLUNIT_ASSERT_EQUAL((int)data[2], 0x00);
40
41        LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 0], 0xff);
42        LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 1], 0xff);
43        LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 2], 0xff);
44
45        delete image;
46    }
47};
48
49} /* namespace lol */
50
Note: See TracBrowser for help on using the repository browser.