summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <chris@Burninator.(none)>2007-06-22 23:39:34 +1000
committerChristopher James Halse Rogers <chris@Burninator.(none)>2007-06-22 23:39:34 +1000
commit6f857ad2227c48d055f0fcc1c05155eb6bc53753 (patch)
tree9fe53d43fd1fa6516c0c0adfd5c541a508e811a5
parent8b5c6fa72e80c5705f5c5fe96538009e0b751ce2 (diff)
downloadradial-switcher-6f857ad2227c48d055f0fcc1c05155eb6bc53753.tar.gz
radial-switcher-6f857ad2227c48d055f0fcc1c05155eb6bc53753.tar.bz2
We're looking like a library at this point. I want some unittests!
Add an autotools build system, and configure check so that I can satisfy my craving for red-green-refactor
-rw-r--r--Makefile270
-rw-r--r--Makefile.am3
-rw-r--r--configure.ac46
-rw-r--r--plugin.info4
-rw-r--r--src/Makefile.am4
-rw-r--r--src/switcher-util.c (renamed from radial-switcher.c)163
-rw-r--r--tests/Makefile.am7
-rw-r--r--tests/check_switcher-util.c73
8 files changed, 136 insertions, 434 deletions
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 6075055..0000000
--- a/Makefile
+++ /dev/null
@@ -1,270 +0,0 @@
-##
-#
-# Compiz plugin Makefile
-#
-# Copyright : (C) 2006 by Dennis Kasprzyk
-# E-mail : onestone@deltatauchi.de
-#
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-##
-
-#load config file
-include plugin.info
-
-
-ifeq ($(BUILD_GLOBAL),true)
- PREFIX = $(shell pkg-config --variable=prefix compiz)
- CLIBDIR = $(shell pkg-config --variable=libdir compiz)
- CINCDIR = $(shell pkg-config --variable=includedir compiz)
- PKGDIR = $(CLIBDIR)/pkgconfig
- DESTDIR = $(shell pkg-config --variable=libdir compiz)/compiz
- XMLDIR = $(shell pkg-config --variable=prefix compiz)/share/compiz
-else
- DESTDIR = $(HOME)/.compiz/plugins
- XMLDIR = $(HOME)/.compiz/metadata
-endif
-
-BUILDDIR = build
-
-CC = gcc
-LIBTOOL = libtool
-INSTALL = install
-
-BCOP = `pkg-config --variable=bin bcop`
-
-CFLAGS = -g -Wall `pkg-config --cflags $(PKG_DEP) compiz ` $(CFLAGS_ADD)
-LDFLAGS = `pkg-config --libs $(PKG_DEP) compiz ` $(LDFLAGS_ADD)
-
-is-bcop-target := $(shell if [ -e $(PLUGIN).xml ]; then cat $(PLUGIN).xml | grep "useBcop=\"true\"";fi )
-
-bcop-target := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(PLUGIN).xml; fi )
-bcop-target-src := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(BUILDDIR)/$(PLUGIN)_options.c; fi )
-bcop-target-hdr := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(BUILDDIR)/$(PLUGIN)_options.h; fi )
-
-gen-schemas := $(shell if [ -e $(PLUGIN).xml ] && [ -n `pkg-config --variable=xsltdir compiz-gconf` ]; then echo true; fi )
-schema-target := $(shell if [ -n "$(gen-schemas)" ]; then echo $(PLUGIN).xml; fi )
-schema-output := $(shell if [ -n "$(gen-schemas)" ]; then echo $(BUILDDIR)/compiz-$(PLUGIN).schema; fi )
-
-ifeq ($(BUILD_GLOBAL),true)
- pkg-target := $(shell if [ -e compiz-$(PLUGIN).pc.in -a -n "$(PREFIX)" -a -d "$(PREFIX)" ]; then echo "$(BUILDDIR)/compiz-$(PLUGIN).pc"; fi )
- hdr-install-target := $(shell if [ -e compiz-$(PLUGIN).pc.in -a -n "$(PREFIX)" -a -d "$(PREFIX)" -a -e $(PLUGIN).h ]; then echo "$(PLUGIN).h"; fi )
-endif
-
-# find all the object files (including those from .moc.cpp files)
-
-c-objs := $(patsubst %.c,%.lo,$(shell find -name '*.c' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
-c-objs := $(filter-out $(bcop-target-src:.c=.lo),$(c-objs))
-
-all-c-objs := $(addprefix $(BUILDDIR)/,$(c-objs))
-all-c-objs += $(bcop-target-src:.c=.lo)
-
-# system include path parameter, -isystem doesn't work on old gcc's
-inc-path-param = $(shell if [ -z "`gcc --version | head -n 1 | grep ' 3'`" ]; then echo "-isystem"; else echo "-I"; fi)
-
-# default color settings
-color := $(shell if [ $$TERM = "dumb" ]; then echo "no"; else echo "yes"; fi)
-
-#
-# Do it.
-#
-
-.PHONY: $(BUILDDIR) build-dir bcop-build pkg-creation schema-creation c-build-objs c-link-plugin
-
-all: $(BUILDDIR) build-dir bcop-build pkg-creation schema-creation c-build-objs c-link-plugin
-
-bcop-build: $(bcop-target-hdr) $(bcop-target-src)
-
-schema-creation: $(schema-output)
-
-c-build-objs: $(all-c-objs)
-
-c-link-plugin: $(BUILDDIR)/lib$(PLUGIN).la
-
-pkg-creation: $(pkg-target)
-
-#
-# Create build directory
-#
-
-$(BUILDDIR) :
- @mkdir -p $(BUILDDIR)
-
-$(DESTDIR) :
- @mkdir -p $(DESTDIR)
-
-#
-# BCOP'ing
-
-$(BUILDDIR)/%_options.h: %.xml
- @if [ '$(color)' != 'no' ]; then \
- echo -e -n "\033[0;1;5mbcop'ing \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
- else \
- echo "bcop'ing $< -> $@"; \
- fi
- @$(BCOP) --header=$@ $<
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mbcop'ing : \033[34m$< -> $@\033[0m"; \
- fi
-
-$(BUILDDIR)/%_options.c: %.xml
- @if [ '$(color)' != 'no' ]; then \
- echo -e -n "\033[0;1;5mbcop'ing \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
- else \
- echo "bcop'ing $< -> $@"; \
- fi
- @$(BCOP) --source=$@ $<
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mbcop'ing : \033[34m$< -> $@\033[0m"; \
- fi
-
-#
-# Schema generation
-
-$(BUILDDIR)/compiz-%.schema: %.xml
- @if [ '$(color)' != 'no' ]; then \
- echo -e -n "\033[0;1;5mschema'ing\033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
- else \
- echo "schema'ing $< -> $@"; \
- fi
- @xsltproc `pkg-config --variable=xsltdir compiz-gconf`/schemas.xslt $< > $@
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mschema : \033[34m$< -> $@\033[0m"; \
- fi
-
-#
-# pkg config file generation
-
-$(BUILDDIR)/compiz-%.pc: compiz-%.pc.in
- @if [ '$(color)' != 'no' ]; then \
- echo -e -n "\033[0;1;5mpkgconfig \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
- else \
- echo "pkgconfig $< -> $@"; \
- fi
- @COMPIZREQUIRES=`cat $(PKGDIR)/compiz.pc | grep Requires | sed -e 's;Requires: ;;g'`; \
- COMPIZCFLAGS=`cat $(PKGDIR)/compiz.pc | grep Cflags | sed -e 's;Cflags: ;;g'`; \
- sed -e 's;@prefix@;$(PREFIX);g' -e 's;\@libdir@;$(CLIBDIR);g' \
- -e 's;@includedir@;$(CINCDIR);g' -e 's;\@VERSION@;0.0.1;g' \
- -e "s;@COMPIZ_REQUIRES@;$$COMPIZREQUIRES;g" \
- -e "s;@COMPIZ_CFLAGS@;$$COMPIZCFLAGS;g" $< > $@;
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mpkgconfig : \033[34m$< -> $@\033[0m"; \
- fi
-
-#
-# Compiling
-#
-
-$(BUILDDIR)/%.lo: %.c
- @if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5mcompiling \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
- else \
- echo "compiling $< -> $@"; \
- fi
- @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) -I$(BUILDDIR) -c -o $@ $<
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
- fi
-
-$(BUILDDIR)/%.lo: $(BUILDDIR)/%.c
- @if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5mcompiling \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
- else \
- echo "compiling $< -> $@"; \
- fi
- @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) -I$(BUILDDIR) -c -o $@ $<
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
- fi
-
-
-#
-# Linking
-#
-
-cxx-rpath-prefix := -Wl,-rpath,
-
-$(BUILDDIR)/lib$(PLUGIN).la: $(addprefix $(BUILDDIR)/,$(c-objs))
- @if [ '$(color)' != 'no' ]; then \
- echo -e -n "\033[0;1;5mlinking -> \033[0;31m$@\033[0m"; \
- else \
- echo "linking -> $@"; \
- fi
- @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(all-c-objs)
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mlinking -> \033[34m$@\033[0m"; \
- fi
-
-
-clean:
- rm -rf $(BUILDDIR)
-
-install: $(DESTDIR) all
- @if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
- else \
- echo "install : $(DESTDIR)/lib$(PLUGIN).so"; \
- fi
- @mkdir -p $(DESTDIR)
- @$(INSTALL) $(BUILDDIR)/.libs/lib$(PLUGIN).so $(DESTDIR)/lib$(PLUGIN).so
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0minstall : \033[34m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
- fi
- @if [ -e $(PLUGIN).xml ]; then \
- if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
- else \
- echo "install : $(XMLDIR)/$(PLUGIN).xml"; \
- fi; \
- mkdir -p $(XMLDIR); \
- cp $(PLUGIN).xml $(XMLDIR)/$(PLUGIN).xml; \
- if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0minstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
- fi; \
- fi
- @if [ -n "$(hdr-install-target)" ]; then \
- if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
- else \
- echo "install : $(CINCDIR)/compiz/$(hdr-install-target)"; \
- fi; \
- cp $(hdr-install-target) $(CINCDIR)/compiz/$(hdr-install-target); \
- if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0minstall : \033[34m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
- fi; \
- fi
- @if [ -n "$(pkg-target)" ]; then \
- if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
- else \
- echo "install : $(PKGDIR)/compiz-$(PLUGIN).pc"; \
- fi; \
- cp $(pkg-target) $(PKGDIR)/compiz-$(PLUGIN).pc; \
- if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0minstall : \033[34m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
- fi; \
- fi
- @if [ -e $(schema-output) ]; then \
- if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(schema-output)\033[0m"; \
- else \
- echo "install : $(schema-output)"; \
- fi; \
- gconftool-2 --install-schema-file=$(schema-output) > /dev/null; \
- if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0minstall : \033[34m$(schema-output)\033[0m"; \
- fi; \
- fi
-
-
-
-
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..8376833
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,3 @@
+## Process this file with automake to produce Makefile.in
+
+SUBDIRS = src . tests \ No newline at end of file
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..6c1f2e3
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,46 @@
+# Process this file with autoconf to produce a configure script.
+
+# Prelude.
+AC_PREREQ([2.59])
+AC_INIT([Money], [0.3], [chalserogers@gmail.com])
+
+# unique source file --- primitive safety check
+AC_CONFIG_SRCDIR([src/switcher-util.c])
+
+# place to put some extra build scripts installed
+AC_CONFIG_AUX_DIR([build-aux])
+
+# fairly severe build strictness
+# change foreign to gnu or gnits to comply with gnu standards
+AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.9.6])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+# Checks for libraries.
+
+# This macro is defined in check.m4 and tests if check.h and
+# libcheck.a are installed in your system. It sets CHECK_CFLAGS and
+# CHECK_LIBS accordingly.
+# AM_PATH_CHECK([MINIMUM-VERSION,
+# [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
+AM_PATH_CHECK()
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([stdlib.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+
+# Output files
+AC_CONFIG_HEADERS([config.h])
+
+AC_CONFIG_FILES([Makefile
+ src/Makefile
+ tests/Makefile])
+
+AC_OUTPUT
diff --git a/plugin.info b/plugin.info
deleted file mode 100644
index 529a928..0000000
--- a/plugin.info
+++ /dev/null
@@ -1,4 +0,0 @@
-PLUGIN = radial-switcher
-PKG_DEP = cairo
-LDFLAGS_ADD =
-CFLAGS_ADD =
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..17fe22b
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,4 @@
+## Process this file with automake to produce Makefile.in
+
+lib_LTLIBRARIES = libswitcher-util.la
+libswitcher_util_la_SOURCES = switcher-util.c switcher-util.h \ No newline at end of file
diff --git a/radial-switcher.c b/src/switcher-util.c
index ca8289b..e46dcd5 100644
--- a/radial-switcher.c
+++ b/src/switcher-util.c
@@ -1,22 +1,18 @@
/**
*
- * Compiz radial-switcher plugin
+ * Compiz switcher utility library
*
- * radial-switcher.c
+ * switcher-utils.c
*
* Copyright © 2007 Christopher James Halse Rogers <chalserogers@gmail.com>
*
* Authors:
* Christopher James Halse Rogers <chalserogers@gmail.com>
*
- * Based on scale.c and switcher.c:
+ * Based on switcher.c:
* Copyright : (C) 2007 David Reveman
* E-mail : davidr@novell.com
*
- * Cairo usage based on wall.c
- * Copyright : (C) 2007 Robert Carr
- * E-mail : racarr@beryl-project.org
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -29,17 +25,7 @@
*
**/
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <X11/Xatom.h>
-#include <X11/extensions/Xrender.h>
-
-#include <cairo.h>
#include <compiz.h>
@@ -55,16 +41,6 @@ typedef struct _WindowTree {
struct _WindowTree **children;
} WindowTree;
-typedef struct _RadialCairoContext
-{
- Pixmap pixmap;
- CompTexture texture;
- cairo_surface_t *surface;
- cairo_t *cr;
- int width;
- int height;
-} RadialCairoContext;
-
typedef Bool (*WindowCmpProc)(CompWindow *a, CompWindow *b);
typedef Bool (*WindowFilterProc)(CompWindow *a);
@@ -202,136 +178,3 @@ createWindowTree (WindowList *windows,
}
return root;
}
-
-/*
-static void
-radialSetupCairoContext(CompScreen *s, RadialCairoContext *context)
-{
- XRenderPictFormat * format;
- Screen * screen;
-
- screen = ScreenOfDisplay(s->display->display, s->screenNum);
-
- int width, height;
- width = context->width;
- height = context->height;
-
- initTexture(s, &context->texture);
-
- format = XRenderFindStandardFormat(s->display->display, PictStandardARGB32);
-
- context->pixmap = XCreatePixmap(s->display->display, s->root,
- width, height, 32);
-
- if (!bindPixmapToTexture(s, &context->texture, context->pixmap,
- width, height, 32))
- compLogMessage (s->display, "radial-switcher", CompLogLevelError,
- "Couldn't create cairo context for switcher");
-
- context->surface = cairo_xlib_surface_create_with_xrender_format(s->display->display, context->pixmap, screen, format, width, height);
- context->cr = cairo_create(context->surface);
-
- cairo_t *cr = context->cr;
- cairo_save(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
- cairo_paint(cr);
- cairo_restore(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
-}
-*/
-/*
-static Bool
-isSwitchWin (CompWindow *w)
-{
- SWITCH_SCREEN (w->screen);
-
- if (!w->mapNum || w->attrib.map_state != IsViewable)
- {
- if (ss->opt[SWITCH_SCREEN_OPTION_MINIMIZED].value.b)
- {
- if (!w->minimized && !w->inShowDesktopMode && !w->shaded)
- return FALSE;
- }
- else
- {
- return FALSE;
- }
- }
-
- if (w->attrib.override_redirect)
- return FALSE;
-
- if (w->wmType & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
- return FALSE;
-
- if (w->state & CompWindowStateSkipTaskbarMask)
- return FALSE;
-
- if (!ss->allWindows)
- {
- if (!w->mapNum || w->attrib.map_state != IsViewable)
- {
- if (w->serverX + w->width <= 0 ||
- w->serverY + w->height <= 0 ||
- w->serverX >= w->screen->width ||
- w->serverY >= w->screen->height)
- return FALSE;
- }
- else
- {
- if (!(*w->screen->focusWindow) (w))
- return FALSE;
- }
- }
-
- if (!matchEval (&ss->opt[SWITCH_SCREEN_OPTION_WINDOW_MATCH].value.match, w))
- return FALSE;
-
- return TRUE;
-}
-
-static int
-compareWindows (const void *elem1,
- const void *elem2)
-{
- CompWindow *w1 = *((CompWindow **) elem1);
- CompWindow *w2 = *((CompWindow **) elem2);
-
- if (w1->mapNum && !w2->mapNum)
- return -1;
-
- if (w2->mapNum && !w1->mapNum)
- return 1;
-
- return w2->activeNum - w1->activeNum;
-}
-
-
-static void
-switchCreateWindowList (CompScreen *s,
- int count)
-{
- CompWindow *w;
-
- SWITCH_SCREEN (s);
-
- ss->nWindows = 0;
-
- for (w = s->windows; w; w = w->next)
- {
- if (isSwitchWin (w))
- switchAddWindowToList (s, w);
- }
-
- qsort (ss->windows, ss->nWindows, sizeof (CompWindow *), compareWindows);
-
- if (ss->nWindows == 2)
- {
- switchAddWindowToList (s, ss->windows[0]);
- switchAddWindowToList (s, ss->windows[1]);
- }
-
- switchUpdateWindowList (s, count);
-}
-
-*/
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..990665e
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,7 @@
+## Process this file with automake to produce Makefile.in
+
+TESTS = check_switcher-util
+check_PROGRAMS = check_swicher-util
+check_switcher_util_SOURCES = check_switcher-util.c $(top_builddir)/src/switcher-util.h
+check_switcher_util_CFLAGS = @CHECK_CFLAGS@
+check_switcher_util_LDADD = @CHECK_LIBS@ $(top_builddir)/src/libswitcher-util.la
diff --git a/tests/check_switcher-util.c b/tests/check_switcher-util.c
new file mode 100644
index 0000000..991611a
--- /dev/null
+++ b/tests/check_switcher-util.c
@@ -0,0 +1,73 @@
+#include <stdlib.h>
+#include <check.h>
+#include "../src/switcher-util.h"
+
+void
+setup (void)
+{
+ five_dollars = money_create (5, "USD");
+}
+
+void
+teardown (void)
+{
+ money_free (five_dollars);
+}
+
+START_TEST (test_money_create)
+{
+ fail_unless (money_amount (five_dollars) == 5,
+ "Amount not set correctly on creation");
+ fail_unless (strcmp (money_currency (five_dollars), "USD") == 0,
+ "Currency not set correctly on creation");
+}
+END_TEST
+
+START_TEST (test_money_create_neg)
+{
+ Money *m = money_create (-1, "USD");
+ fail_unless (m == NULL,
+ "NULL should be returned on attempt to create with "
+ "a negative amount");
+}
+END_TEST
+
+START_TEST (test_money_create_zero)
+{
+ Money *m = money_create (0, "USD");
+ fail_unless (money_amount (m) == 0,
+ "Zero is a valid amount of money");
+}
+END_TEST
+
+Suite *
+money_suite (void)
+{
+ Suite *s = suite_create ("Money");
+
+ /* Core test case */
+ TCase *tc_core = tcase_create ("Core");
+ tcase_add_checked_fixture (tc_core, setup, teardown);
+ tcase_add_test (tc_core, test_money_create);
+ suite_add_tcase (s, tc_core);
+
+ /* Limits test case */
+ TCase *tc_limits = tcase_create ("Limits");
+ tcase_add_test (tc_limits, test_money_create_neg);
+ tcase_add_test (tc_limits, test_money_create_zero);
+ suite_add_tcase (s, tc_limits);
+
+ return s;
+}
+
+int
+main (void)
+{
+ int number_failed;
+ Suite *s = money_suite ();
+ SRunner *sr = srunner_create (s);
+ srunner_run_all (sr, CK_NORMAL);
+ number_failed = srunner_ntests_failed (sr);
+ srunner_free (sr);
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}