File: t_null_error.c

package info (click to toggle)
webp-pixbuf-loader 0.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,144 kB
  • sloc: ansic: 1,194; sh: 17; makefile: 7
file content (50 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download | duplicates (2)
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
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glib/gstdio.h>

static gchar *
create_filename ()
{
  GString *pathbuild = g_string_new (g_get_tmp_dir ());
  gchar   *id        = g_uuid_string_random ();
  g_string_append_printf (pathbuild, "%s%s.webp", G_DIR_SEPARATOR_S, id);
  g_free (id);
  return g_string_free (pathbuild, FALSE);
}

gboolean
save_func (const gchar *buffer, gsize count, GError **error, gpointer data)
{
  return TRUE;
}

void
test_pixbufv (GdkPixbuf *pixbuf, gchar **keys, gchar **values)
{
  GStatBuf tmpstat = { 0 };
  gchar   *path    = create_filename ();
  g_assert (gdk_pixbuf_savev (pixbuf, path, "webp", keys, values, NULL));
  g_stat (path, &tmpstat);
  g_remove (path);
  g_free (path);

  g_assert (gdk_pixbuf_save_to_callbackv (pixbuf, save_func, NULL, "webp", keys, values, NULL));
}

int
main ()
{
  gchar **env = g_get_environ ();

  GdkPixbuf *pixbuf
      = gdk_pixbuf_new_from_file (g_environ_getenv (env, "TEST_FILE"), NULL);
  g_assert (pixbuf != NULL);
  g_clear_pointer (&env, g_strfreev);

  gchar *keys[2]   = { "icc-profile", NULL };
  gchar *values[2] = { "MQo=", NULL };

  test_pixbufv (pixbuf, NULL, NULL);
  test_pixbufv (pixbuf, keys, values);

  g_object_unref (pixbuf);
}