1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/* Test for the is_instance_of_* functions. */
#include <config.h>
#include "textstyle.h"
#include <stdio.h>
#include <stdlib.h>
#define ASSERT(x) if (!(x)) abort ()
int
main ()
{
ostream_t stream1 = file_ostream_create (stdout);
ostream_t stream2 = fd_ostream_create (1, "(stdout)", false);
ostream_t stream3 = term_ostream_create (1, "(stdout)", TTYCTL_AUTO);
ostream_t stream4 = memory_ostream_create ();
ostream_t stream5 = html_ostream_create (stream1);
ostream_t sstream1 =
term_styled_ostream_create (1, "(stdout)", TTYCTL_AUTO,
SRCDIR "../adhoc-tests/hello-default.css");
ostream_t sstream2 =
html_styled_ostream_create (stream5,
SRCDIR "../adhoc-tests/hello-default.css");
ostream_t sstream3 = noop_styled_ostream_create (stream1, false);
if (stream1 != NULL)
{
ASSERT (! is_instance_of_styled_ostream (stream1));
ASSERT (is_instance_of_file_ostream (stream1));
ASSERT (! is_instance_of_fd_ostream (stream1));
ASSERT (! is_instance_of_term_ostream (stream1));
ASSERT (! is_instance_of_memory_ostream (stream1));
ASSERT (! is_instance_of_iconv_ostream (stream1));
ASSERT (! is_instance_of_html_ostream (stream1));
ASSERT (! is_instance_of_term_styled_ostream (stream1));
ASSERT (! is_instance_of_html_styled_ostream (stream1));
ASSERT (! is_instance_of_noop_styled_ostream (stream1));
}
if (stream2 != NULL)
{
ASSERT (! is_instance_of_styled_ostream (stream2));
ASSERT (! is_instance_of_file_ostream (stream2));
ASSERT (is_instance_of_fd_ostream (stream2));
ASSERT (! is_instance_of_term_ostream (stream2));
ASSERT (! is_instance_of_memory_ostream (stream2));
ASSERT (! is_instance_of_iconv_ostream (stream2));
ASSERT (! is_instance_of_html_ostream (stream2));
ASSERT (! is_instance_of_term_styled_ostream (stream2));
ASSERT (! is_instance_of_html_styled_ostream (stream2));
ASSERT (! is_instance_of_noop_styled_ostream (stream2));
}
if (stream3 != NULL)
{
ASSERT (! is_instance_of_styled_ostream (stream3));
ASSERT (! is_instance_of_file_ostream (stream3));
ASSERT (! is_instance_of_fd_ostream (stream3));
ASSERT (is_instance_of_term_ostream (stream3));
ASSERT (! is_instance_of_memory_ostream (stream3));
ASSERT (! is_instance_of_iconv_ostream (stream3));
ASSERT (! is_instance_of_html_ostream (stream3));
ASSERT (! is_instance_of_term_styled_ostream (stream3));
ASSERT (! is_instance_of_html_styled_ostream (stream3));
ASSERT (! is_instance_of_noop_styled_ostream (stream3));
}
if (stream4 != NULL)
{
ASSERT (! is_instance_of_styled_ostream (stream4));
ASSERT (! is_instance_of_file_ostream (stream4));
ASSERT (! is_instance_of_fd_ostream (stream4));
ASSERT (! is_instance_of_term_ostream (stream4));
ASSERT (is_instance_of_memory_ostream (stream4));
ASSERT (! is_instance_of_iconv_ostream (stream4));
ASSERT (! is_instance_of_html_ostream (stream4));
ASSERT (! is_instance_of_term_styled_ostream (stream4));
ASSERT (! is_instance_of_html_styled_ostream (stream4));
ASSERT (! is_instance_of_noop_styled_ostream (stream4));
}
if (stream5 != NULL)
{
ASSERT (! is_instance_of_styled_ostream (stream5));
ASSERT (! is_instance_of_file_ostream (stream5));
ASSERT (! is_instance_of_fd_ostream (stream5));
ASSERT (! is_instance_of_term_ostream (stream5));
ASSERT (! is_instance_of_memory_ostream (stream5));
ASSERT (! is_instance_of_iconv_ostream (stream5));
ASSERT (is_instance_of_html_ostream (stream5));
ASSERT (! is_instance_of_term_styled_ostream (stream5));
ASSERT (! is_instance_of_html_styled_ostream (stream5));
ASSERT (! is_instance_of_noop_styled_ostream (stream5));
}
if (sstream1 != NULL)
{
ASSERT (is_instance_of_styled_ostream (sstream1));
ASSERT (! is_instance_of_file_ostream (sstream1));
ASSERT (! is_instance_of_fd_ostream (sstream1));
ASSERT (! is_instance_of_term_ostream (sstream1));
ASSERT (! is_instance_of_memory_ostream (sstream1));
ASSERT (! is_instance_of_iconv_ostream (sstream1));
ASSERT (! is_instance_of_html_ostream (sstream1));
ASSERT (is_instance_of_term_styled_ostream (sstream1));
ASSERT (! is_instance_of_html_styled_ostream (sstream1));
ASSERT (! is_instance_of_noop_styled_ostream (sstream1));
}
if (sstream2 != NULL)
{
ASSERT (is_instance_of_styled_ostream (sstream2));
ASSERT (! is_instance_of_file_ostream (sstream2));
ASSERT (! is_instance_of_fd_ostream (sstream2));
ASSERT (! is_instance_of_term_ostream (sstream2));
ASSERT (! is_instance_of_memory_ostream (sstream2));
ASSERT (! is_instance_of_iconv_ostream (sstream2));
ASSERT (! is_instance_of_html_ostream (sstream2));
ASSERT (! is_instance_of_term_styled_ostream (sstream2));
ASSERT (is_instance_of_html_styled_ostream (sstream2));
ASSERT (! is_instance_of_noop_styled_ostream (sstream2));
}
if (sstream3 != NULL)
{
ASSERT (is_instance_of_styled_ostream (sstream3));
ASSERT (! is_instance_of_file_ostream (sstream3));
ASSERT (! is_instance_of_fd_ostream (sstream3));
ASSERT (! is_instance_of_term_ostream (sstream3));
ASSERT (! is_instance_of_memory_ostream (sstream3));
ASSERT (! is_instance_of_iconv_ostream (sstream3));
ASSERT (! is_instance_of_html_ostream (sstream3));
ASSERT (! is_instance_of_term_styled_ostream (sstream3));
ASSERT (! is_instance_of_html_styled_ostream (sstream3));
ASSERT (is_instance_of_noop_styled_ostream (sstream3));
}
return 0;
}
|