File: autoptr.c

package info (click to toggle)
glib2.0 2.86.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 73,060 kB
  • sloc: ansic: 544,382; python: 9,702; sh: 1,612; xml: 1,482; perl: 1,222; cpp: 535; makefile: 321; javascript: 11
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 ();
}