From: Behdad Esfahbod Date: Fri, 27 May 2011 05:00:55 +0000 (-0400) Subject: [test/version] Test hb-version.h X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9313b9aa66a82fd3fa60d8417c22a5350e5a8791;p=platform%2Fupstream%2FlibHarfBuzzSharp.git [test/version] Test hb-version.h --- diff --git a/test/Makefile.am b/test/Makefile.am index 973d6b4..bfa423b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -19,6 +19,7 @@ TEST_PROGS += \ test-object \ test-shape \ test-unicode \ + test-version \ $(NULL) TEST_PROGS += \ diff --git a/test/test-version.c b/test/test-version.c new file mode 100644 index 0000000..4c9bd37 --- /dev/null +++ b/test/test-version.c @@ -0,0 +1,80 @@ +/* + * Copyright © 2011 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#include "hb-test.h" + +/* Unit tests for hb-version.h */ + + +static void +test_version (void) +{ + unsigned int major, minor, micro; + char *s; + + hb_version (&major, &minor, µ); + + g_assert_cmpint (major, ==, HB_VERSION_MAJOR); + g_assert_cmpint (minor, ==, HB_VERSION_MINOR); + g_assert_cmpint (micro, ==, HB_VERSION_MICRO); + + s = g_strdup_printf ("%u.%u.%u", major, minor, micro); + g_assert (0 == strcmp (HB_VERSION_STRING, s)); + g_free (s); + g_assert (0 == strcmp (HB_VERSION_STRING, hb_version_string ())); + + g_assert (HB_VERSION_CHECK (major, minor, micro)); + g_assert (HB_VERSION_CHECK (major+1, minor, micro)); + g_assert (HB_VERSION_CHECK (major, minor+1, micro)); + g_assert (HB_VERSION_CHECK (major, minor, micro+1)); + if (major) + g_assert (!HB_VERSION_CHECK (major-1, minor, micro)); + if (minor) + g_assert (!HB_VERSION_CHECK (major, minor-1, micro)); + if (micro) + g_assert (!HB_VERSION_CHECK (major, minor, micro-1)); + + g_assert (hb_version_check (major, minor, micro)); + g_assert (hb_version_check (major+1, minor, micro)); + g_assert (hb_version_check (major, minor+1, micro)); + g_assert (hb_version_check (major, minor, micro+1)); + if (major) + g_assert (!hb_version_check (major-1, minor, micro)); + if (minor) + g_assert (!hb_version_check (major, minor-1, micro)); + if (micro) + g_assert (!hb_version_check (major, minor, micro-1)); +} + +int +main (int argc, char **argv) +{ + hb_test_init (&argc, &argv); + + hb_test_add (test_version); + + return hb_test_run(); +}