* libtextstyle/install-tests/test-version.c: New file.
* libtextstyle/install-tests/test-api.c: New file.
* libtextstyle/install-tests/Makefile.am: New file.
* libtextstyle/configure.ac (AUGMENT_SHLIBPATH): New variable.
(AC_CONFIG_FILES): Add install-tests/Makefile.
* libtextstyle/Makefile.am (SUBDIRS): Add install-tests.
## Makefile for the toplevel directory of GNU libtextstyle
-## Copyright (C) 1995-2024 Free Software Foundation, Inc.
+## Copyright (C) 1995-2025 Free Software Foundation, Inc.
##
## 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
ACLOCAL_AMFLAGS = -I m4 -I gnulib-m4
# The list of subdirectories containing Makefiles.
-SUBDIRS = lib tests adhoc-tests doc
+SUBDIRS = lib tests adhoc-tests install-tests doc
EXTRA_DIST = \
version.sh \
AC_PATH_PROG([DVIPS], [dvips], [$ac_aux_dir_abs/missing dvips])
AC_PATH_PROG([PERL], [perl], [$ac_aux_dir_abs/missing perl])
+dnl Test for features used in install-tests.
+dnl shlibpath_var and PATH_SEPARATOR are set by LT_INIT.
+if test -n "${shlibpath_var}"; then
+ if test "${shlibpath_var}" = PATH; then
+ AUGMENT_SHLIBPATH="PATH='\$(bindir)'${PATH_SEPARATOR}\"\$\$PATH\";"
+ else
+ AUGMENT_SHLIBPATH="${shlibpath_var}='\$(libdir)':\"\$\$${shlibpath_var}\"; export ${shlibpath_var};"
+ fi
+else
+ AUGMENT_SHLIBPATH=
+fi
+AC_SUBST([AUGMENT_SHLIBPATH])
+
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([doc/Makefile])
AC_CONFIG_FILES([lib/Makefile])
AC_CONFIG_FILES([lib/textstyle/woe32dll.h:lib/textstyle/woe32dll.in.h])
AC_CONFIG_FILES([tests/Makefile])
AC_CONFIG_FILES([adhoc-tests/Makefile])
+AC_CONFIG_FILES([install-tests/Makefile])
AC_OUTPUT
--- /dev/null
+## Makefile for libtextstyle/install-tests.
+## Copyright (C) 2025 Free Software Foundation, Inc.
+##
+## 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 3 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.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+## Process this file with automake to produce Makefile.in.
+
+installcheck-local:
+ $(CC) -I$(includedir) -L$(libdir) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+ -o test-version $(srcdir)/test-version.c -ltextstyle
+ @AUGMENT_SHLIBPATH@ ./test-version
+ rm -rf test-version test-version$(EXEEXT)
+ $(CC) -I$(includedir) -L$(libdir) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ -DTOP_SRCDIR=\"$(top_srcdir)/\" \
+ $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+ -o test-api $(srcdir)/test-api.c -ltextstyle
+ @AUGMENT_SHLIBPATH@ ./test-api
+ rm -rf test-api test-api$(EXEEXT)
+
+EXTRA_DIST = test-version.c test-api.c
+CLEANFILES = test-version test-version$(EXEEXT) test-api test-api$(EXEEXT)
--- /dev/null
+/* Test parts of the API.
+ Copyright (C) 2018-2025 Free Software Foundation, Inc.
+
+ 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 3 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2025. */
+
+#include <textstyle.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main ()
+{
+ /* Test based on libtextstyle/adhoc-tests/hello.c. */
+
+ memory_ostream_t mstream = memory_ostream_create ();
+
+ style_file_name = TOP_SRCDIR "adhoc-tests/hello-default.css";
+ styled_ostream_t stream =
+ html_styled_ostream_create (mstream, style_file_name);
+
+ ostream_write_str (stream, "Hello ");
+
+ /* Associate the entire full name in CSS class 'name'. */
+ styled_ostream_begin_use_class (stream, "name");
+
+ ostream_write_str (stream, "Dr. ");
+ styled_ostream_begin_use_class (stream, "boy-name");
+ /* Start a hyperlink. */
+ styled_ostream_set_hyperlink (stream, "https://en.wikipedia.org/wiki/Linus_Pauling", NULL);
+ ostream_write_str (stream, "Linus");
+ styled_ostream_end_use_class (stream, "boy-name");
+ ostream_write_str (stream, " Pauling");
+ /* End the current hyperlink. */
+ styled_ostream_set_hyperlink (stream, NULL, NULL);
+
+ /* Terminate the name. */
+ styled_ostream_end_use_class (stream, "name");
+
+ ostream_write_str (stream, "!\n");
+
+ /* Flush and close the stream. */
+ styled_ostream_free (stream);
+
+ const void *buf;
+ size_t buflen;
+ memory_ostream_contents (mstream, &buf, &buflen);
+
+ const char *expected =
+ "<?xml version=\"1.0\"?>\n"
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
+ "<html>\n"
+ "<head>\n"
+ "<style type=\"text/css\">\n"
+ "<!--\n"
+ "/* This file is in the public domain.\n"
+ "\n"
+ " Styling rules for the color-hello example. */\n"
+ "\n"
+ ".name { text-decoration : underline; }\n"
+ ".boy-name { background-color : rgb(123,201,249); }\n"
+ ".girl-name { background-color : rgb(250,149,158); }\n"
+ "-->\n"
+ "</style>\n"
+ "</head>\n"
+ "<body>\n"
+ "Hello <span class=\"name\">Dr. </span><a href=\"https://en.wikipedia.org/wiki/Linus_Pauling\"><span class=\"name\"><span class=\"boy-name\">Linus</span> Pauling</span></a>!<br/></body>\n"
+ "</html>\n";
+ assert (buflen == strlen (expected));
+ assert (memcmp ((const char *) buf, expected, buflen) == 0);
+
+ ostream_free (mstream);
+
+ return 0;
+}
--- /dev/null
+/* Test the version information.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+
+ 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 3 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2025. */
+
+#include <textstyle.h>
+
+#include <stdio.h>
+
+int
+main ()
+{
+ if (!(_libtextstyle_version == _LIBTEXTSTYLE_VERSION))
+ {
+ fprintf (stderr, "Installation problem: include file says version 0x%x, whereas library says version 0x%x\n",
+ _LIBTEXTSTYLE_VERSION, _libtextstyle_version);
+ return 1;
+ }
+ return 0;
+}