File: autoptr.c

package info (click to toggle)
gobject-introspection 1.74.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 68,092 kB
  • sloc: ansic: 524,161; xml: 32,098; python: 21,234; yacc: 1,707; perl: 1,411; sh: 1,044; lex: 499; cpp: 171; makefile: 77; lisp: 1
file content (23 lines) | stat: -rw-r--r-- 548 bytes parent folder | download | duplicates (14)
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 ();
}