Просмотр исходного кода

* Started libcaca unit tests.

tags/v0.99.beta14
Sam Hocevar sam 16 лет назад
Родитель
Сommit
d202c8242f
5 измененных файлов: 94 добавлений и 12 удалений
  1. +1
    -0
      tests/.gitignore
  2. +8
    -3
      tests/Makefile.am
  3. +29
    -0
      tests/caca-test.cpp
  4. +8
    -9
      tests/canvas.cpp
  5. +48
    -0
      tests/driver.cpp

+ 1
- 0
tests/.gitignore Просмотреть файл

@@ -1,2 +1,3 @@
simple
cucul-test
caca-test

+ 8
- 3
tests/Makefile.am Просмотреть файл

@@ -1,9 +1,10 @@
# $Id$

AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/cucul -I../cucul
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/cucul -I../cucul \
-I$(top_srcdir)/caca

if USE_CPPUNIT
cppunit_tests = cucul-test
cppunit_tests = cucul-test caca-test
endif

noinst_PROGRAMS = simple $(cppunit_tests)
@@ -14,6 +15,10 @@ simple_SOURCES = simple.c
simple_LDADD = ../cucul/libcucul.la

cucul_test_SOURCES = cucul-test.cpp canvas.cpp
cucul_test_CPPFLAGS = $(CPPUNIT_CFLAGS)
cucul_test_CXXFLAGS = $(CPPUNIT_CFLAGS)
cucul_test_LDADD = ../cucul/libcucul.la $(CPPUNIT_LIBS)

caca_test_SOURCES = caca-test.cpp driver.cpp
caca_test_CXXFLAGS = $(CPPUNIT_CFLAGS)
caca_test_LDADD = ../caca/libcaca.la $(CPPUNIT_LIBS)


+ 29
- 0
tests/caca-test.cpp Просмотреть файл

@@ -0,0 +1,29 @@
/*
* caca-test testsuite program for libcaca
* Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* This program 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.
*/

#include "config.h"

#include <cppunit/TextTestRunner.h>
#include <cppunit/extensions/TestFactoryRegistry.h>

int main(int argc, char *argv[])
{
CppUnit::TextTestRunner runner;
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());

runner.run();

return 0;
}


+ 8
- 9
tests/canvas.cpp Просмотреть файл

@@ -1,7 +1,6 @@
/*
* cucul-test testsuite program for libcucul
* Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
* Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
@@ -52,20 +51,20 @@ public:
cucul_canvas_t *cv;

cv = cucul_create_canvas(0, 0);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 0U);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 0U);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 0);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 0);

cucul_set_canvas_size(cv, 1, 1);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 1U);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 1U);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 1);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 1);

cucul_set_canvas_size(cv, 1234, 1001);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 1234U);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 1001U);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 1234);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 1001);

cucul_set_canvas_size(cv, 0, 0);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 0U);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 0U);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 0);
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 0);

cucul_free_canvas(cv);
}


+ 48
- 0
tests/driver.cpp Просмотреть файл

@@ -0,0 +1,48 @@
/*
* caca-test testsuite program for libcaca
* Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* This program 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.
*/

#include "config.h"

#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestCaller.h>
#include <cppunit/TestCase.h>
#include <cppunit/TestSuite.h>

#include "caca.h"

class DriverTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(DriverTest);
CPPUNIT_TEST(test_list);
CPPUNIT_TEST_SUITE_END();

public:
DriverTest() : CppUnit::TestCase("Driver Test") {}

void setUp() {}

void tearDown() {}

void test_list()
{
char const * const * list;

list = caca_get_display_driver_list();
CPPUNIT_ASSERT(list != NULL);
CPPUNIT_ASSERT(list[0] != NULL);
}
};

CPPUNIT_TEST_SUITE_REGISTRATION(DriverTest);


Загрузка…
Отмена
Сохранить