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

Last change on this file since 2183 was 2183, checked in by sam, 7 years ago

build: fix the WTFPL site URL in all code comments.

  • Property svn:keywords set to Id
File size: 1.1 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://www.wtfpl.net/ 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("data/gradient.png");
28
29        ivec2 size = image.GetSize();
30        LOLUNIT_ASSERT_EQUAL(size.x, 256);
31        LOLUNIT_ASSERT_EQUAL(size.y, 16);
32
33        uint8_t *data = (uint8_t *)image.GetData();
34        LOLUNIT_ASSERT(data);
35
36        LOLUNIT_ASSERT_EQUAL((int)data[0], 0x00);
37        LOLUNIT_ASSERT_EQUAL((int)data[1], 0x00);
38        LOLUNIT_ASSERT_EQUAL((int)data[2], 0x00);
39
40        LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 0], 0xff);
41        LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 1], 0xff);
42        LOLUNIT_ASSERT_EQUAL((int)data[255 * 4 + 2], 0xff);
43    }
44};
45
46} /* namespace lol */
47
Note: See TracBrowser for help on using the repository browser.