File: autoptr.c

package info (click to toggle)
gobject-introspection 1.86.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 72,464 kB
  • sloc: ansic: 562,805; python: 23,750; xml: 16,240; perl: 1,878; yacc: 1,720; sh: 1,139; lex: 513; cpp: 487; makefile: 197; javascript: 15; lisp: 1
file content (23 lines) | stat: -rw-r--r-- 548 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <gio/gio.h>

static void
test_autoptr (void)
{
  g_autoptr(GFile) p = g_file_new_for_path ("/blah");
  g_autoptr(GInetAddress) a = g_inet_address_new_from_string ("127.0.0.1");
  g_autofree gchar *path = g_file_get_path (p);
  g_autofree gchar *istr = g_inet_address_to_string (a);

  g_assert_cmpstr (path, ==, G_DIR_SEPARATOR_S "blah");
  g_assert_cmpstr (istr, ==, "127.0.0.1");
}

int
main (int argc, char *argv[])
{
  g_test_init (&argc, &argv, NULL);

  g_test_add_func ("/autoptr/autoptr", test_autoptr);

  return g_test_run ();
}