~ubuntu-branches/ubuntu/trusty/glib2.0/trusty-proposed

« back to all changes in this revision

Viewing changes to glib/tests/gvariant.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-03-09 11:28:22 UTC
  • mfrom: (3.4.8 experimental)
  • Revision ID: james.westby@ubuntu.com-20100309112822-j4n0v3xbtsup8s97
Tags: 2.23.5-1ubuntu1
* Resync on Debian
* debian/patches/01_gettext-desktopfiles.patch:
  - updated to use gettext for X-GNOME-Fullname too
* debian/patches/71_gio_launch_handler.patch:
  - new gio default launch handle feature required for wncksync
* debian/control.in, 
  debian/patches/80-gtester-subunit.patch:
  - gtester-report subunit support
* debian/libglib2.0-0.symbols:
  - updated the symbols list for the gio launcher handler
* debian/rules:
  - don't break build on test suite errors, debian recently activated this but
    the build breaks even when there is no error in the testsuite

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 * Author: Ryan Lortie <desrt@desrt.ca>
12
12
 */
13
13
 
 
14
#include <glib/gvariant-internal.h>
14
15
#include <string.h>
 
16
#include <stdlib.h>
15
17
#include <glib.h>
16
18
 
17
19
#define BASIC "bynqiuxthdsog?"
645
647
    }
646
648
}
647
649
 
648
 
#undef  G_GNUC_INTERNAL
649
 
#define G_GNUC_INTERNAL static
650
 
 
651
 
#define DISABLE_VISIBILITY
652
 
#define GLIB_COMPILATION
653
 
#include <glib/gvarianttypeinfo.c>
654
 
 
655
650
#define ALIGNED(x, y)   (((x + (y - 1)) / y) * y)
656
651
 
657
652
/* do our own calculation of the fixed_size and alignment of a type
1027
1022
      g_free (desc);
1028
1023
    }
1029
1024
 
1030
 
  assert_no_type_infos ();
 
1025
  g_variant_type_info_assert_no_infos ();
1031
1026
}
1032
1027
 
1033
 
#include <glib/gvariant-serialiser.c>
1034
 
 
1035
1028
#define MAX_FIXED_MULTIPLIER    256
1036
1029
#define MAX_INSTANCE_SIZE       1024
1037
1030
#define MAX_ARRAY_CHILDREN      128
1384
1377
  for (i = 0; i < 1000; i++)
1385
1378
    test_maybe ();
1386
1379
 
1387
 
  assert_no_type_infos ();
 
1380
  g_variant_type_info_assert_no_infos ();
1388
1381
}
1389
1382
 
1390
1383
static void
1523
1516
  for (i = 0; i < 100; i++)
1524
1517
    test_array ();
1525
1518
 
1526
 
  assert_no_type_infos ();
 
1519
  g_variant_type_info_assert_no_infos ();
1527
1520
}
1528
1521
 
1529
1522
static void
1683
1676
  for (i = 0; i < 100; i++)
1684
1677
    test_tuple ();
1685
1678
 
1686
 
  assert_no_type_infos ();
 
1679
  g_variant_type_info_assert_no_infos ();
1687
1680
}
1688
1681
 
1689
1682
static void
1756
1749
  for (i = 0; i < 100; i++)
1757
1750
    test_variant ();
1758
1751
 
1759
 
  assert_no_type_infos ();
 
1752
  g_variant_type_info_assert_no_infos ();
1760
1753
}
1761
1754
 
1762
1755
static void
2184
2177
  for (i = 0; i < 200; i++)
2185
2178
    test_byteswap ();
2186
2179
 
2187
 
  assert_no_type_infos ();
 
2180
  g_variant_type_info_assert_no_infos ();
2188
2181
}
2189
2182
 
2190
2183
static void
2254
2247
  for (i = 0; i < 200; i++)
2255
2248
    test_fuzz (&fuzziness);
2256
2249
 
2257
 
  assert_no_type_infos ();
 
2250
  g_variant_type_info_assert_no_infos ();
2258
2251
}
2259
2252
 
2260
2253
static GVariant *
2269
2262
    {
2270
2263
    case G_VARIANT_TYPE_INFO_CHAR_MAYBE:
2271
2264
      {
 
2265
        const GVariantType *child_type;
2272
2266
        GVariant *child;
2273
2267
 
2274
2268
        if (tree->n_children)
2276
2270
        else
2277
2271
          child = NULL;
2278
2272
 
2279
 
        result = g_variant_new_maybe (g_variant_type_element (type), child);
 
2273
        child_type = g_variant_type_element (type);
 
2274
 
 
2275
        if (child != NULL && randomly (0.5))
 
2276
          child_type = NULL;
 
2277
 
 
2278
        result = g_variant_new_maybe (child_type, child);
2280
2279
      }
2281
2280
      break;
2282
2281
 
2283
2282
    case G_VARIANT_TYPE_INFO_CHAR_ARRAY:
2284
2283
      {
 
2284
        const GVariantType *child_type;
2285
2285
        GVariant **children;
2286
2286
        gint i;
2287
2287
 
2289
2289
        for (i = 0; i < tree->n_children; i++)
2290
2290
          children[i] = tree_instance_get_gvariant (tree->children[i]);
2291
2291
 
2292
 
        result = g_variant_new_array (g_variant_type_element (type),
2293
 
                                      children, tree->n_children);
 
2292
        child_type = g_variant_type_element (type);
 
2293
 
 
2294
        if (i > 0 && randomly (0.5))
 
2295
          child_type = NULL;
 
2296
 
 
2297
        result = g_variant_new_array (child_type, children, tree->n_children);
2294
2298
        g_free (children);
2295
2299
      }
2296
2300
      break;
2392
2396
  return result;
2393
2397
}
2394
2398
 
2395
 
static void
2396
 
test_constructor (void)
 
2399
static gboolean
 
2400
tree_instance_check_gvariant (TreeInstance *tree,
 
2401
                              GVariant     *value)
 
2402
{
 
2403
  const GVariantType *type;
 
2404
 
 
2405
  type = (GVariantType *) g_variant_type_info_get_type_string (tree->info);
 
2406
  g_assert (g_variant_is_of_type (value, type));
 
2407
 
 
2408
  switch (g_variant_type_info_get_type_char (tree->info))
 
2409
    {
 
2410
    case G_VARIANT_TYPE_INFO_CHAR_MAYBE:
 
2411
      {
 
2412
        GVariant *child;
 
2413
        gboolean equal;
 
2414
 
 
2415
        child = g_variant_get_maybe (value);
 
2416
 
 
2417
        if (child != NULL && tree->n_children == 1)
 
2418
          equal = tree_instance_check_gvariant (tree->children[0], child);
 
2419
        else if (child == NULL && tree->n_children == 0)
 
2420
          equal = TRUE;
 
2421
        else
 
2422
          equal = FALSE;
 
2423
 
 
2424
        if (child != NULL)
 
2425
          g_variant_unref (child);
 
2426
 
 
2427
        return equal;
 
2428
      }
 
2429
      break;
 
2430
 
 
2431
    case G_VARIANT_TYPE_INFO_CHAR_ARRAY:
 
2432
    case G_VARIANT_TYPE_INFO_CHAR_TUPLE:
 
2433
    case G_VARIANT_TYPE_INFO_CHAR_DICT_ENTRY:
 
2434
      {
 
2435
        gsize i;
 
2436
 
 
2437
        if (g_variant_n_children (value) != tree->n_children)
 
2438
          return FALSE;
 
2439
 
 
2440
        for (i = 0; i < tree->n_children; i++)
 
2441
          {
 
2442
            GVariant *child;
 
2443
            gboolean equal;
 
2444
 
 
2445
            child = g_variant_get_child_value (value, i);
 
2446
            equal = tree_instance_check_gvariant (tree->children[i], child);
 
2447
            g_variant_unref (child);
 
2448
 
 
2449
            if (!equal)
 
2450
              return FALSE;
 
2451
          }
 
2452
 
 
2453
        return TRUE;
 
2454
      }
 
2455
      break;
 
2456
 
 
2457
    case G_VARIANT_TYPE_INFO_CHAR_VARIANT:
 
2458
      {
 
2459
        const gchar *str1, *str2;
 
2460
        GVariant *child;
 
2461
        gboolean equal;
 
2462
 
 
2463
        child = g_variant_get_variant (value);
 
2464
        str1 = g_variant_get_type_string (child);
 
2465
        str2 = g_variant_type_info_get_type_string (tree->children[0]->info);
 
2466
        /* GVariant only keeps one copy of type strings around */
 
2467
        equal = str1 == str2 &&
 
2468
                tree_instance_check_gvariant (tree->children[0], child);
 
2469
 
 
2470
        g_variant_unref (child);
 
2471
 
 
2472
        return equal;
 
2473
      }
 
2474
      break;
 
2475
 
 
2476
    case 'b':
 
2477
      return g_variant_get_boolean (value) == tree->data.integer;
 
2478
 
 
2479
    case 'y':
 
2480
      return g_variant_get_byte (value) == (guchar) tree->data.integer;
 
2481
 
 
2482
    case 'n':
 
2483
      return g_variant_get_int16 (value) == (gint16) tree->data.integer;
 
2484
 
 
2485
    case 'q':
 
2486
      return g_variant_get_uint16 (value) == (guint16) tree->data.integer;
 
2487
 
 
2488
    case 'i':
 
2489
      return g_variant_get_int32 (value) == (gint32) tree->data.integer;
 
2490
 
 
2491
    case 'u':
 
2492
      return g_variant_get_uint32 (value) == (guint32) tree->data.integer;
 
2493
 
 
2494
    case 'x':
 
2495
      return g_variant_get_int64 (value) == (gint64) tree->data.integer;
 
2496
 
 
2497
    case 't':
 
2498
      return g_variant_get_uint64 (value) == (guint64) tree->data.integer;
 
2499
 
 
2500
    case 'h':
 
2501
      return g_variant_get_handle (value) == (gint32) tree->data.integer;
 
2502
 
 
2503
    case 'd':
 
2504
      {
 
2505
        gdouble floating = g_variant_get_double (value);
 
2506
 
 
2507
        return memcmp (&floating, &tree->data.floating, sizeof floating) == 0;
 
2508
      }
 
2509
 
 
2510
    case 's':
 
2511
    case 'o':
 
2512
    case 'g':
 
2513
      return strcmp (g_variant_get_string (value, NULL),
 
2514
                     tree->data.string) == 0;
 
2515
 
 
2516
    default:
 
2517
      g_assert_not_reached ();
 
2518
    }
 
2519
}
 
2520
 
 
2521
static void
 
2522
tree_instance_build_gvariant (TreeInstance    *tree,
 
2523
                              GVariantBuilder *builder,
 
2524
                              gboolean         guess_ok)
 
2525
{
 
2526
  const GVariantType *type;
 
2527
 
 
2528
  type = (GVariantType *) g_variant_type_info_get_type_string (tree->info);
 
2529
 
 
2530
  if (g_variant_type_is_container (type))
 
2531
    {
 
2532
      gsize i;
 
2533
 
 
2534
      /* force GVariantBuilder to guess the type half the time */
 
2535
      if (guess_ok && randomly (0.5))
 
2536
        {
 
2537
          if (g_variant_type_is_array (type) && tree->n_children)
 
2538
            type = G_VARIANT_TYPE_ARRAY;
 
2539
 
 
2540
          if (g_variant_type_is_maybe (type) && tree->n_children)
 
2541
            type = G_VARIANT_TYPE_MAYBE;
 
2542
 
 
2543
          if (g_variant_type_is_tuple (type))
 
2544
            type = G_VARIANT_TYPE_TUPLE;
 
2545
 
 
2546
          if (g_variant_type_is_dict_entry (type))
 
2547
            type = G_VARIANT_TYPE_DICT_ENTRY;
 
2548
        }
 
2549
      else
 
2550
        guess_ok = FALSE;
 
2551
 
 
2552
      g_variant_builder_open (builder, type);
 
2553
 
 
2554
      for (i = 0; i < tree->n_children; i++)
 
2555
        tree_instance_build_gvariant (tree->children[i], builder, guess_ok);
 
2556
 
 
2557
      g_variant_builder_close (builder);
 
2558
    }
 
2559
  else
 
2560
    g_variant_builder_add_value (builder, tree_instance_get_gvariant (tree));
 
2561
}
 
2562
 
 
2563
 
 
2564
static gboolean
 
2565
tree_instance_check_iter (TreeInstance *tree,
 
2566
                          GVariantIter *iter)
 
2567
{
 
2568
  GVariant *value;
 
2569
 
 
2570
  value = g_variant_iter_next_value (iter);
 
2571
 
 
2572
  if (g_variant_is_container (value))
 
2573
    {
 
2574
      gsize i;
 
2575
 
 
2576
      iter = g_variant_iter_new (value);
 
2577
      g_variant_unref (value);
 
2578
 
 
2579
      if (g_variant_iter_n_children (iter) != tree->n_children)
 
2580
        {
 
2581
          g_variant_iter_free (iter);
 
2582
          return FALSE;
 
2583
        }
 
2584
 
 
2585
      for (i = 0; i < tree->n_children; i++)
 
2586
        if (!tree_instance_check_iter (tree->children[i], iter))
 
2587
          {
 
2588
            g_variant_iter_free (iter);
 
2589
            return FALSE;
 
2590
          }
 
2591
 
 
2592
      g_assert (g_variant_iter_next_value (iter) == NULL);
 
2593
      g_variant_iter_free (iter);
 
2594
 
 
2595
      return TRUE;
 
2596
    }
 
2597
 
 
2598
  else
 
2599
    {
 
2600
      gboolean equal;
 
2601
 
 
2602
      equal = tree_instance_check_gvariant (tree, value);
 
2603
      g_variant_unref (value);
 
2604
 
 
2605
      return equal;
 
2606
    }
 
2607
}
 
2608
 
 
2609
static void
 
2610
test_container (void)
2397
2611
{
2398
2612
  TreeInstance *tree;
2399
2613
  GVariant *value;
2403
2617
  value = g_variant_ref_sink (tree_instance_get_gvariant (tree));
2404
2618
 
2405
2619
  s1 = g_variant_print (value, TRUE);
 
2620
  g_assert (tree_instance_check_gvariant (tree, value));
 
2621
 
2406
2622
  g_variant_get_data (value);
 
2623
 
2407
2624
  s2 = g_variant_print (value, TRUE);
 
2625
  g_assert (tree_instance_check_gvariant (tree, value));
2408
2626
 
2409
2627
  g_assert_cmpstr (s1, ==, s2);
 
2628
 
 
2629
  if (g_variant_is_container (value))
 
2630
    {
 
2631
      GVariantBuilder builder;
 
2632
      GVariantIter iter;
 
2633
      GVariant *built;
 
2634
      GVariant *val;
 
2635
      gchar *s3;
 
2636
 
 
2637
      g_variant_builder_init (&builder, G_VARIANT_TYPE_VARIANT);
 
2638
      tree_instance_build_gvariant (tree, &builder, TRUE);
 
2639
      built = g_variant_builder_end (&builder);
 
2640
      g_variant_ref_sink (built);
 
2641
      g_variant_get_data (built);
 
2642
      val = g_variant_get_variant (built);
 
2643
 
 
2644
      s3 = g_variant_print (val, TRUE);
 
2645
      g_assert_cmpstr (s1, ==, s3);
 
2646
 
 
2647
      g_variant_iter_init (&iter, built);
 
2648
      g_assert (tree_instance_check_iter (tree, &iter));
 
2649
      g_assert (g_variant_iter_next_value (&iter) == NULL);
 
2650
 
 
2651
      g_variant_unref (built);
 
2652
      g_variant_unref (val);
 
2653
      g_free (s3);
 
2654
    }
 
2655
 
2410
2656
  tree_instance_free (tree);
2411
2657
  g_variant_unref (value);
2412
2658
  g_free (s2);
2414
2660
}
2415
2661
 
2416
2662
static void
2417
 
test_constructors (void)
2418
 
{
2419
 
  gint i;
2420
 
 
2421
 
  for (i = 0; i < 1000; i++)
2422
 
    {
2423
 
      test_constructor ();
2424
 
    }
 
2663
test_containers (void)
 
2664
{
 
2665
  gint i;
 
2666
 
 
2667
  for (i = 0; i < 100; i++)
 
2668
    {
 
2669
      test_container ();
 
2670
    }
 
2671
 
 
2672
  g_variant_type_info_assert_no_infos ();
 
2673
}
 
2674
 
 
2675
static void
 
2676
test_format_strings (void)
 
2677
{
 
2678
  GVariantType *type;
 
2679
  const gchar *end;
 
2680
 
 
2681
  g_assert (g_variant_format_string_scan ("i", NULL, &end) && *end == '\0');
 
2682
  g_assert (g_variant_format_string_scan ("@i", NULL, &end) && *end == '\0');
 
2683
  g_assert (g_variant_format_string_scan ("@ii", NULL, &end) && *end == 'i');
 
2684
  g_assert (g_variant_format_string_scan ("^a&s", NULL, &end) && *end == '\0');
 
2685
  g_assert (g_variant_format_string_scan ("(^as)", NULL, &end) &&
 
2686
            *end == '\0');
 
2687
  g_assert (!g_variant_format_string_scan ("(^s)", NULL, &end));
 
2688
  g_assert (!g_variant_format_string_scan ("(^a)", NULL, &end));
 
2689
  g_assert (!g_variant_format_string_scan ("(z)", NULL, &end));
 
2690
  g_assert (!g_variant_format_string_scan ("az", NULL, &end));
 
2691
  g_assert (!g_variant_format_string_scan ("{**}", NULL, &end));
 
2692
  g_assert (!g_variant_format_string_scan ("{@**}", NULL, &end));
 
2693
  g_assert (g_variant_format_string_scan ("{@y*}", NULL, &end) &&
 
2694
            *end == '\0');
 
2695
  g_assert (g_variant_format_string_scan ("{yv}", NULL, &end) &&
 
2696
            *end == '\0');
 
2697
  g_assert (!g_variant_format_string_scan ("{vv}", NULL, &end));
 
2698
  g_assert (!g_variant_format_string_scan ("{y}", NULL, &end));
 
2699
  g_assert (!g_variant_format_string_scan ("{yyy}", NULL, &end));
 
2700
  g_assert (!g_variant_format_string_scan ("{ya}", NULL, &end));
 
2701
  g_assert (g_variant_format_string_scan ("&s", NULL, &end) && *end == '\0');
 
2702
  g_assert (!g_variant_format_string_scan ("&as", NULL, &end));
 
2703
  g_assert (!g_variant_format_string_scan ("@z", NULL, &end));
 
2704
  g_assert (!g_variant_format_string_scan ("az", NULL, &end));
 
2705
  g_assert (!g_variant_format_string_scan ("a&s", NULL, &end));
 
2706
 
 
2707
  type = g_variant_format_string_scan_type ("mm(@xy^a&s*?@?)", NULL, &end);
 
2708
  g_assert (type && *end == '\0');
 
2709
  g_assert (g_variant_type_equal (type, G_VARIANT_TYPE ("mm(xyas*?\?)")));
 
2710
  g_variant_type_free (type);
 
2711
 
 
2712
  type = g_variant_format_string_scan_type ("mm(@xy^a&*?@?)", NULL, NULL);
 
2713
  g_assert (type == NULL);
 
2714
}
 
2715
 
 
2716
static void
 
2717
exit_on_abort (int signal)
 
2718
{
 
2719
  exit (signal);
 
2720
}
 
2721
 
 
2722
static gboolean
 
2723
do_failed_test (const gchar *pattern)
 
2724
{
 
2725
  if (g_test_trap_fork (1000000, G_TEST_TRAP_SILENCE_STDERR))
 
2726
    {
 
2727
      signal (SIGABRT, exit_on_abort);
 
2728
      return TRUE;
 
2729
    }
 
2730
 
 
2731
  g_test_trap_assert_failed ();
 
2732
  g_test_trap_assert_stderr (pattern);
 
2733
 
 
2734
  return FALSE;
 
2735
}
 
2736
 
 
2737
static void
 
2738
test_invalid_varargs (void)
 
2739
{
 
2740
  if (do_failed_test ("*not a valid GVariant format string*"))
 
2741
    {
 
2742
      g_variant_new ("z");
 
2743
      abort ();
 
2744
    }
 
2745
 
 
2746
  if (do_failed_test ("*valid GVariant format string as a prefix*"))
 
2747
    {
 
2748
      const gchar *end;
 
2749
 
 
2750
      g_variant_new_va ("z", &end, NULL);
 
2751
      abort ();
 
2752
    }
 
2753
 
 
2754
  if (do_failed_test ("*type of `q' but * has a type of `y'*"))
 
2755
    {
 
2756
      g_variant_get (g_variant_new ("y", 'a'), "q");
 
2757
      abort ();
 
2758
    }
 
2759
}
 
2760
 
 
2761
static void
 
2762
check_and_free (GVariant    *value,
 
2763
                const gchar *str)
 
2764
{
 
2765
  gchar *valstr = g_variant_print (value, FALSE);
 
2766
  g_assert_cmpstr (str, ==, valstr);
 
2767
  g_variant_unref (value);
 
2768
  g_free (valstr);
 
2769
}
 
2770
 
 
2771
static void
 
2772
test_varargs (void)
 
2773
{
 
2774
  {
 
2775
    GVariantBuilder array;
 
2776
 
 
2777
    g_variant_builder_init (&array, G_VARIANT_TYPE_ARRAY);
 
2778
    g_variant_builder_add (&array, "{sv}", "size",
 
2779
                           g_variant_new ("(ii)", 800, 600));
 
2780
    g_variant_builder_add (&array, "{sv}", "title",
 
2781
                           g_variant_new_string ("Test case"));
 
2782
    g_variant_builder_add_value (&array,
 
2783
      g_variant_new_dict_entry (g_variant_new_string ("temperature"),
 
2784
                                g_variant_new_variant (
 
2785
                                  g_variant_new_double (37.5))));
 
2786
    check_and_free (g_variant_new ("(ma{sv}m(a{sv})ma{sv}ii)",
 
2787
                                   NULL, FALSE, NULL, &array, 7777, 8888),
 
2788
                    "(Nothing, Nothing, {'size': <(800, 600)>, "
 
2789
                                        "'title': <'Test case'>, "
 
2790
                                        "'temperature': <37.5>}, "
 
2791
                     "7777, 8888)");
 
2792
 
 
2793
    check_and_free (g_variant_new ("(imimimmimmimmi)",
 
2794
                                   123,
 
2795
                                   FALSE, 321,
 
2796
                                   TRUE, 123,
 
2797
                                   FALSE, TRUE, 321,
 
2798
                                   TRUE, FALSE, 321,
 
2799
                                   TRUE, TRUE, 123),
 
2800
                    "(123, Nothing, 123, Nothing, Just Nothing, 123)");
 
2801
 
 
2802
    check_and_free (g_variant_new ("(ybnixd)",
 
2803
                                   'a', 1, 22, 33, (guint64) 44, 5.5),
 
2804
                    "(0x61, true, 22, 33, 44, 5.5)");
 
2805
 
 
2806
    check_and_free (g_variant_new ("(@y?*rv)",
 
2807
                                   g_variant_new ("y", 'a'),
 
2808
                                   g_variant_new ("y", 'b'),
 
2809
                                   g_variant_new ("y", 'c'),
 
2810
                                   g_variant_new ("(y)", 'd'),
 
2811
                                   g_variant_new ("y", 'e')),
 
2812
                    "(0x61, 0x62, 0x63, (0x64,), <byte 0x65>)");
 
2813
  }
 
2814
 
 
2815
  {
 
2816
    GVariantBuilder array;
 
2817
    GVariantIter iter;
 
2818
    GVariant *value;
 
2819
    gchar *number;
 
2820
    gboolean just;
 
2821
    gint i, val;
 
2822
 
 
2823
    g_variant_builder_init (&array, G_VARIANT_TYPE_ARRAY);
 
2824
    for (i = 0; i < 100; i++)
 
2825
      {
 
2826
        number = g_strdup_printf ("%d", i);
 
2827
        g_variant_builder_add (&array, "s", number);
 
2828
        g_free (number);
 
2829
      }
 
2830
 
 
2831
    value = g_variant_builder_end (&array);
 
2832
    g_variant_iter_init (&iter, value);
 
2833
 
 
2834
    i = 0;
 
2835
    while (g_variant_iter_loop (&iter, "s", &number))
 
2836
      {
 
2837
        gchar *check = g_strdup_printf ("%d", i++);
 
2838
        g_assert_cmpstr (number, ==, check);
 
2839
        g_free (check);
 
2840
      }
 
2841
    g_assert (number == NULL);
 
2842
    g_assert (i == 100);
 
2843
 
 
2844
    g_variant_unref (value);
 
2845
 
 
2846
    g_variant_builder_init (&array, G_VARIANT_TYPE_ARRAY);
 
2847
    for (i = 0; i < 100; i++)
 
2848
      g_variant_builder_add (&array, "mi", i % 2 == 0, i);
 
2849
    value = g_variant_builder_end (&array);
 
2850
 
 
2851
    i = 0;
 
2852
    g_variant_iter_init (&iter, value);
 
2853
    while (g_variant_iter_loop (&iter, "mi", NULL, &val))
 
2854
      g_assert (val == i++ || val == 0);
 
2855
    g_assert (i == 100);
 
2856
 
 
2857
    i = 0;
 
2858
    g_variant_iter_init (&iter, value);
 
2859
    while (g_variant_iter_loop (&iter, "mi", &just, &val))
 
2860
      {
 
2861
        gint this = i++;
 
2862
 
 
2863
        if (this % 2 == 0)
 
2864
          {
 
2865
            g_assert (just);
 
2866
            g_assert (val == this);
 
2867
          }
 
2868
        else
 
2869
          {
 
2870
            g_assert (!just);
 
2871
            g_assert (val == 0);
 
2872
          }
 
2873
      }
 
2874
    g_assert (i == 100);
 
2875
 
 
2876
    g_variant_unref (value);
 
2877
  }
 
2878
 
 
2879
  {
 
2880
    const gchar *strvector[] = {"/hello", "/world", NULL};
 
2881
    const gchar *test_strs[] = {"/foo", "/bar", "/baz" };
 
2882
    GVariantBuilder builder;
 
2883
    GVariantIter *array;
 
2884
    GVariantIter tuple;
 
2885
    const gchar **strv;
 
2886
    gchar **my_strv;
 
2887
    GVariant *value;
 
2888
    gchar *str;
 
2889
    gint i;
 
2890
 
 
2891
    g_variant_builder_init (&builder, G_VARIANT_TYPE ("ao"));
 
2892
    g_variant_builder_add (&builder, "o", "/foo");
 
2893
    g_variant_builder_add (&builder, "o", "/bar");
 
2894
    g_variant_builder_add (&builder, "o", "/baz");
 
2895
    value = g_variant_new("(ao^ao^a&o)", &builder, strvector, strvector);
 
2896
    g_variant_iter_init (&tuple, value);
 
2897
    g_variant_iter_next (&tuple, "ao", &array);
 
2898
 
 
2899
    i = 0;
 
2900
    while (g_variant_iter_loop (array, "o", &str))
 
2901
      g_assert_cmpstr (str, ==, test_strs[i++]);
 
2902
    g_assert (i == 3);
 
2903
 
 
2904
    g_variant_iter_free (array);
 
2905
 
 
2906
    /* start over */
 
2907
    g_variant_iter_init (&tuple, value);
 
2908
    g_variant_iter_next (&tuple, "ao", &array);
 
2909
 
 
2910
    i = 0;
 
2911
    while (g_variant_iter_loop (array, "&o", &str))
 
2912
      g_assert_cmpstr (str, ==, test_strs[i++]);
 
2913
    g_assert (i == 3);
 
2914
 
 
2915
    g_variant_iter_free (array);
 
2916
 
 
2917
    g_variant_iter_next (&tuple, "^a&o", &strv);
 
2918
    g_variant_iter_next (&tuple, "^ao", &my_strv);
 
2919
 
 
2920
    g_assert_cmpstr (strv[0], ==, "/hello");
 
2921
    g_assert_cmpstr (strv[1], ==, "/world");
 
2922
    g_assert (strv[2] == NULL);
 
2923
    g_assert_cmpstr (my_strv[0], ==, "/hello");
 
2924
    g_assert_cmpstr (my_strv[1], ==, "/world");
 
2925
    g_assert (my_strv[2] == NULL);
 
2926
 
 
2927
    g_variant_unref (value);
 
2928
    g_strfreev (my_strv);
 
2929
    g_free (strv);
 
2930
  }
 
2931
 
 
2932
  {
 
2933
    const gchar *strvector[] = { "i", "ii", "iii", "iv", "v", "vi", NULL };
 
2934
    GVariantBuilder builder;
 
2935
    GVariantIter iter;
 
2936
    GVariantIter *i2;
 
2937
    GVariantIter *i3;
 
2938
    GVariant *value;
 
2939
    GVariant *sub;
 
2940
    gchar **strv;
 
2941
    gint i;
 
2942
 
 
2943
    g_variant_builder_init (&builder, G_VARIANT_TYPE ("aag"));
 
2944
    g_variant_builder_open (&builder, G_VARIANT_TYPE ("ag"));
 
2945
    for (i = 0; i < 6; i++)
 
2946
      if (i & 1)
 
2947
        g_variant_builder_add (&builder, "g", strvector[i]);
 
2948
      else
 
2949
        g_variant_builder_add (&builder, "&g", strvector[i]);
 
2950
    g_variant_builder_close (&builder);
 
2951
    g_variant_builder_add (&builder, "^ag", strvector);
 
2952
    g_variant_builder_add (&builder, "^ag", strvector);
 
2953
    value = g_variant_new ("aag", &builder);
 
2954
 
 
2955
    g_variant_iter_init (&iter, value);
 
2956
    while (g_variant_iter_loop (&iter, "^ag", &strv))
 
2957
      for (i = 0; i < 6; i++)
 
2958
        g_assert_cmpstr (strv[i], ==, strvector[i]);
 
2959
 
 
2960
    g_variant_iter_init (&iter, value);
 
2961
    while (g_variant_iter_loop (&iter, "^a&g", &strv))
 
2962
      for (i = 0; i < 6; i++)
 
2963
        g_assert_cmpstr (strv[i], ==, strvector[i]);
 
2964
 
 
2965
    g_variant_iter_init (&iter, value);
 
2966
    while (g_variant_iter_loop (&iter, "ag", &i2))
 
2967
      {
 
2968
        gchar *str;
 
2969
 
 
2970
        i = 0;
 
2971
        while (g_variant_iter_loop (i2, "g", &str))
 
2972
          g_assert_cmpstr (str, ==, strvector[i++]);
 
2973
        g_assert (i == 6);
 
2974
      }
 
2975
 
 
2976
    g_variant_iter_init (&iter, value);
 
2977
    i3 = g_variant_iter_copy (&iter);
 
2978
    while (g_variant_iter_loop (&iter, "@ag", &sub))
 
2979
      {
 
2980
        gchar *str = g_variant_print (sub, TRUE);
 
2981
        g_assert_cmpstr (str, ==,
 
2982
                         "[signature 'i', 'ii', 'iii', 'iv', 'v', 'vi']");
 
2983
        g_free (str);
 
2984
      }
 
2985
 
 
2986
  if (do_failed_test ("*NULL has already been returned*"))
 
2987
    {
 
2988
      g_variant_iter_next_value (&iter);
 
2989
      abort ();
 
2990
    }
 
2991
 
 
2992
 
 
2993
    while (g_variant_iter_loop (i3, "*", &sub))
 
2994
      {
 
2995
        gchar *str = g_variant_print (sub, TRUE);
 
2996
        g_assert_cmpstr (str, ==,
 
2997
                         "[signature 'i', 'ii', 'iii', 'iv', 'v', 'vi']");
 
2998
        g_free (str);
 
2999
      }
 
3000
 
 
3001
    g_variant_iter_free (i3);
 
3002
 
 
3003
    for (i = 0; i < g_variant_n_children (value); i++)
 
3004
      {
 
3005
        gint j;
 
3006
 
 
3007
        g_variant_get_child (value, i, "*", &sub);
 
3008
 
 
3009
        for (j = 0; j < g_variant_n_children (sub); j++)
 
3010
          {
 
3011
            const gchar *str = NULL;
 
3012
            GVariant *cval;
 
3013
 
 
3014
            g_variant_get_child (sub, j, "&g", &str);
 
3015
            g_assert_cmpstr (str, ==, strvector[j]);
 
3016
 
 
3017
            cval = g_variant_get_child_value (sub, j);
 
3018
            g_variant_get (cval, "&g", &str);
 
3019
            g_assert_cmpstr (str, ==, strvector[j]);
 
3020
            g_variant_unref (cval);
 
3021
          }
 
3022
 
 
3023
        g_variant_unref (sub);
 
3024
      }
 
3025
 
 
3026
    g_variant_unref (value);
 
3027
  }
 
3028
 
 
3029
  {
 
3030
    gboolean justs[10];
 
3031
    GVariant *value;
 
3032
 
 
3033
    GVariant *vval;
 
3034
    guchar byteval;
 
3035
    gboolean bval;
 
3036
    gint16 i16val;
 
3037
    guint16 u16val;
 
3038
    gint32 i32val;
 
3039
    guint32 u32val;
 
3040
    gint64 i64val;
 
3041
    guint64 u64val;
 
3042
    gdouble dval;
 
3043
    gint32 hval;
 
3044
 
 
3045
    /* test all 'Nothing' */
 
3046
    value = g_variant_new ("(mymbmnmqmimumxmtmhmdmv)",
 
3047
                           FALSE, 'a',
 
3048
                           FALSE, TRUE,
 
3049
                           FALSE, (gint16) 123,
 
3050
                           FALSE, (guint16) 123,
 
3051
                           FALSE, (gint32) 123,
 
3052
                           FALSE, (guint32) 123,
 
3053
                           FALSE, (gint64) 123,
 
3054
                           FALSE, (guint64) 123,
 
3055
                           FALSE, (gint32) -1,
 
3056
                           FALSE, (gdouble) 37.5,
 
3057
                           NULL);
 
3058
 
 
3059
    /* both NULL */
 
3060
    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
 
3061
                   NULL, NULL,
 
3062
                   NULL, NULL,
 
3063
                   NULL, NULL,
 
3064
                   NULL, NULL,
 
3065
                   NULL, NULL,
 
3066
                   NULL, NULL,
 
3067
                   NULL, NULL,
 
3068
                   NULL, NULL,
 
3069
                   NULL, NULL,
 
3070
                   NULL, NULL,
 
3071
                   NULL);
 
3072
 
 
3073
    /* NULL values */
 
3074
    memset (justs, 1, sizeof justs);
 
3075
    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
 
3076
                   &justs[0], NULL,
 
3077
                   &justs[1], NULL,
 
3078
                   &justs[2], NULL,
 
3079
                   &justs[3], NULL,
 
3080
                   &justs[4], NULL,
 
3081
                   &justs[5], NULL,
 
3082
                   &justs[6], NULL,
 
3083
                   &justs[7], NULL,
 
3084
                   &justs[8], NULL,
 
3085
                   &justs[9], NULL,
 
3086
                   NULL);
 
3087
    g_assert (!(justs[0] || justs[1] || justs[2] || justs[3] || justs[4] ||
 
3088
                justs[5] || justs[6] || justs[7] || justs[8] || justs[9]));
 
3089
 
 
3090
    /* both non-NULL */
 
3091
    memset (justs, 1, sizeof justs);
 
3092
    byteval = i16val = u16val = i32val = u32val = i64val = u64val = hval = 88;
 
3093
    vval = (void *) 1;
 
3094
    bval = TRUE;
 
3095
    dval = 88.88;
 
3096
    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
 
3097
                   &justs[0], &byteval,
 
3098
                   &justs[1], &bval,
 
3099
                   &justs[2], &i16val,
 
3100
                   &justs[3], &u16val,
 
3101
                   &justs[4], &i32val,
 
3102
                   &justs[5], &u32val,
 
3103
                   &justs[6], &i64val,
 
3104
                   &justs[7], &u64val,
 
3105
                   &justs[8], &hval,
 
3106
                   &justs[9], &dval,
 
3107
                   &vval);
 
3108
    g_assert (!(justs[0] || justs[1] || justs[2] || justs[3] || justs[4] ||
 
3109
                justs[5] || justs[6] || justs[7] || justs[8] || justs[9]));
 
3110
    g_assert (byteval == '\0' && bval == FALSE);
 
3111
    g_assert (i16val == 0 && u16val == 0 && i32val == 0 &&
 
3112
              u32val == 0 && i64val == 0 && u64val == 0 &&
 
3113
              hval == 0 && dval == 0.0);
 
3114
    g_assert (vval == NULL);
 
3115
 
 
3116
    /* NULL justs */
 
3117
    byteval = i16val = u16val = i32val = u32val = i64val = u64val = hval = 88;
 
3118
    vval = (void *) 1;
 
3119
    bval = TRUE;
 
3120
    dval = 88.88;
 
3121
    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
 
3122
                   NULL, &byteval,
 
3123
                   NULL, &bval,
 
3124
                   NULL, &i16val,
 
3125
                   NULL, &u16val,
 
3126
                   NULL, &i32val,
 
3127
                   NULL, &u32val,
 
3128
                   NULL, &i64val,
 
3129
                   NULL, &u64val,
 
3130
                   NULL, &hval,
 
3131
                   NULL, &dval,
 
3132
                   &vval);
 
3133
    g_assert (byteval == '\0' && bval == FALSE);
 
3134
    g_assert (i16val == 0 && u16val == 0 && i32val == 0 &&
 
3135
              u32val == 0 && i64val == 0 && u64val == 0 &&
 
3136
              hval == 0 && dval == 0.0);
 
3137
    g_assert (vval == NULL);
 
3138
 
 
3139
    g_variant_unref (value);
 
3140
 
 
3141
 
 
3142
    /* test all 'Just' */
 
3143
    value = g_variant_new ("(mymbmnmqmimumxmtmhmdmv)",
 
3144
                           TRUE, 'a',
 
3145
                           TRUE, TRUE,
 
3146
                           TRUE, (gint16) 123,
 
3147
                           TRUE, (guint16) 123,
 
3148
                           TRUE, (gint32) 123,
 
3149
                           TRUE, (guint32) 123,
 
3150
                           TRUE, (gint64) 123,
 
3151
                           TRUE, (guint64) 123,
 
3152
                           TRUE, (gint32) -1,
 
3153
                           TRUE, (gdouble) 37.5,
 
3154
                           g_variant_new ("()"));
 
3155
 
 
3156
    /* both NULL */
 
3157
    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
 
3158
                   NULL, NULL,
 
3159
                   NULL, NULL,
 
3160
                   NULL, NULL,
 
3161
                   NULL, NULL,
 
3162
                   NULL, NULL,
 
3163
                   NULL, NULL,
 
3164
                   NULL, NULL,
 
3165
                   NULL, NULL,
 
3166
                   NULL, NULL,
 
3167
                   NULL, NULL,
 
3168
                   NULL);
 
3169
 
 
3170
    /* NULL values */
 
3171
    memset (justs, 0, sizeof justs);
 
3172
    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
 
3173
                   &justs[0], NULL,
 
3174
                   &justs[1], NULL,
 
3175
                   &justs[2], NULL,
 
3176
                   &justs[3], NULL,
 
3177
                   &justs[4], NULL,
 
3178
                   &justs[5], NULL,
 
3179
                   &justs[6], NULL,
 
3180
                   &justs[7], NULL,
 
3181
                   &justs[8], NULL,
 
3182
                   &justs[9], NULL,
 
3183
                   NULL);
 
3184
    g_assert (justs[0] && justs[1] && justs[2] && justs[3] && justs[4] &&
 
3185
              justs[5] && justs[6] && justs[7] && justs[8] && justs[9]);
 
3186
 
 
3187
    /* both non-NULL */
 
3188
    memset (justs, 0, sizeof justs);
 
3189
    byteval = i16val = u16val = i32val = u32val = i64val = u64val = hval = 88;
 
3190
    vval = (void *) 1;
 
3191
    bval = FALSE;
 
3192
    dval = 88.88;
 
3193
    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
 
3194
                   &justs[0], &byteval,
 
3195
                   &justs[1], &bval,
 
3196
                   &justs[2], &i16val,
 
3197
                   &justs[3], &u16val,
 
3198
                   &justs[4], &i32val,
 
3199
                   &justs[5], &u32val,
 
3200
                   &justs[6], &i64val,
 
3201
                   &justs[7], &u64val,
 
3202
                   &justs[8], &hval,
 
3203
                   &justs[9], &dval,
 
3204
                   &vval);
 
3205
    g_assert (justs[0] && justs[1] && justs[2] && justs[3] && justs[4] &&
 
3206
              justs[5] && justs[6] && justs[7] && justs[8] && justs[9]);
 
3207
    g_assert (byteval == 'a' && bval == TRUE);
 
3208
    g_assert (i16val == 123 && u16val == 123 && i32val == 123 &&
 
3209
              u32val == 123 && i64val == 123 && u64val == 123 &&
 
3210
              hval == -1 && dval == 37.5);
 
3211
    g_assert (g_variant_is_of_type (vval, G_VARIANT_TYPE_UNIT));
 
3212
    g_variant_unref (vval);
 
3213
 
 
3214
    /* NULL justs */
 
3215
    byteval = i16val = u16val = i32val = u32val = i64val = u64val = hval = 88;
 
3216
    vval = (void *) 1;
 
3217
    bval = TRUE;
 
3218
    dval = 88.88;
 
3219
    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
 
3220
                   NULL, &byteval,
 
3221
                   NULL, &bval,
 
3222
                   NULL, &i16val,
 
3223
                   NULL, &u16val,
 
3224
                   NULL, &i32val,
 
3225
                   NULL, &u32val,
 
3226
                   NULL, &i64val,
 
3227
                   NULL, &u64val,
 
3228
                   NULL, &hval,
 
3229
                   NULL, &dval,
 
3230
                   &vval);
 
3231
    g_assert (byteval == 'a' && bval == TRUE);
 
3232
    g_assert (i16val == 123 && u16val == 123 && i32val == 123 &&
 
3233
              u32val == 123 && i64val == 123 && u64val == 123 &&
 
3234
              hval == -1 && dval == 37.5);
 
3235
    g_assert (g_variant_is_of_type (vval, G_VARIANT_TYPE_UNIT));
 
3236
    g_variant_unref (vval);
 
3237
 
 
3238
    g_variant_unref (value);
 
3239
  }
 
3240
 
 
3241
  g_variant_type_info_assert_no_infos ();
 
3242
}
 
3243
 
 
3244
static void
 
3245
hash_get (GVariant    *value,
 
3246
          const gchar *format,
 
3247
          ...)
 
3248
{
 
3249
  const gchar *endptr = NULL;
 
3250
  gboolean hash;
 
3251
  va_list ap;
 
3252
 
 
3253
  hash = g_str_has_suffix (format, "#");
 
3254
 
 
3255
  va_start (ap, format);
 
3256
  g_variant_get_va (value, format, hash ? &endptr : NULL, &ap);
 
3257
  va_end (ap);
 
3258
 
 
3259
  if (hash)
 
3260
    g_assert (*endptr == '#');
 
3261
}
 
3262
 
 
3263
static GVariant *
 
3264
hash_new (const gchar *format,
 
3265
          ...)
 
3266
{
 
3267
  const gchar *endptr = NULL;
 
3268
  GVariant *value;
 
3269
  gboolean hash;
 
3270
  va_list ap;
 
3271
 
 
3272
  hash = g_str_has_suffix (format, "#");
 
3273
 
 
3274
  va_start (ap, format);
 
3275
  value = g_variant_new_va (format, hash ? &endptr : NULL, &ap);
 
3276
  va_end (ap);
 
3277
 
 
3278
  if (hash)
 
3279
    g_assert (*endptr == '#');
 
3280
 
 
3281
  return value;
 
3282
}
 
3283
 
 
3284
static void
 
3285
test_valist (void)
 
3286
{
 
3287
  GVariant *value;
 
3288
  gint32 x;
 
3289
 
 
3290
  x = 0;
 
3291
  value = hash_new ("i", 234);
 
3292
  hash_get (value, "i", &x);
 
3293
  g_assert (x == 234);
 
3294
  g_variant_unref (value);
 
3295
 
 
3296
  x = 0;
 
3297
  value = hash_new ("i#", 234);
 
3298
  hash_get (value, "i#", &x);
 
3299
  g_assert (x == 234);
 
3300
  g_variant_unref (value);
 
3301
 
 
3302
  g_variant_type_info_assert_no_infos ();
 
3303
}
 
3304
 
 
3305
static void
 
3306
test_builder_memory (void)
 
3307
{
 
3308
  GVariantBuilder *hb;
 
3309
  GVariantBuilder sb;
 
3310
 
 
3311
  hb = g_variant_builder_new  (G_VARIANT_TYPE_ARRAY);
 
3312
  g_variant_builder_open (hb, G_VARIANT_TYPE_ARRAY);
 
3313
  g_variant_builder_open (hb, G_VARIANT_TYPE_ARRAY);
 
3314
  g_variant_builder_open (hb, G_VARIANT_TYPE_ARRAY);
 
3315
  g_variant_builder_add (hb, "s", "some value");
 
3316
  g_variant_builder_ref (hb);
 
3317
  g_variant_builder_unref (hb);
 
3318
  g_variant_builder_unref (hb);
 
3319
 
 
3320
  hb = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
 
3321
  g_variant_builder_unref (hb);
 
3322
 
 
3323
  hb = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
 
3324
  g_variant_builder_clear (hb);
 
3325
  g_variant_builder_unref (hb);
 
3326
 
 
3327
  g_variant_builder_init (&sb, G_VARIANT_TYPE_ARRAY);
 
3328
  g_variant_builder_open (&sb, G_VARIANT_TYPE_ARRAY);
 
3329
  g_variant_builder_open (&sb, G_VARIANT_TYPE_ARRAY);
 
3330
  g_variant_builder_add (&sb, "s", "some value");
 
3331
  g_variant_builder_clear (&sb);
 
3332
 
 
3333
  g_variant_type_info_assert_no_infos ();
 
3334
}
 
3335
 
 
3336
static void
 
3337
test_hashing (void)
 
3338
{
 
3339
  const gint n_items = 4096;
 
3340
  GVariant *items[n_items];
 
3341
  GHashTable *table;
 
3342
  gint i;
 
3343
 
 
3344
  table = g_hash_table_new_full (g_variant_hash, g_variant_equal,
 
3345
                                 (GDestroyNotify ) g_variant_unref,
 
3346
                                 NULL);
 
3347
 
 
3348
  for (i = 0; i < n_items; i++)
 
3349
    {
 
3350
      TreeInstance *tree;
 
3351
      gint j;
 
3352
 
 
3353
 again:
 
3354
      tree = tree_instance_new (NULL, 0);
 
3355
      items[i] = tree_instance_get_gvariant (tree);
 
3356
      tree_instance_free (tree);
 
3357
 
 
3358
      for (j = 0; j < i; j++)
 
3359
        if (g_variant_equal (items[i], items[j]))
 
3360
          {
 
3361
            g_variant_unref (items[i]);
 
3362
            goto again;
 
3363
          }
 
3364
 
 
3365
      g_hash_table_insert (table,
 
3366
                           g_variant_ref_sink (items[i]),
 
3367
                           GINT_TO_POINTER (i));
 
3368
    }
 
3369
 
 
3370
  for (i = 0; i < n_items; i++)
 
3371
    {
 
3372
      gpointer result;
 
3373
 
 
3374
      result = g_hash_table_lookup (table, items[i]);
 
3375
      g_assert_cmpint (GPOINTER_TO_INT (result), ==, i);
 
3376
    }
 
3377
 
 
3378
  g_hash_table_unref (table);
 
3379
 
 
3380
  g_variant_type_info_assert_no_infos ();
2425
3381
}
2426
3382
 
2427
3383
int
2439
3395
  g_test_add_func ("/gvariant/serialiser/variant", test_variants);
2440
3396
  g_test_add_func ("/gvariant/serialiser/strings", test_strings);
2441
3397
  g_test_add_func ("/gvariant/serialiser/byteswap", test_byteswaps);
2442
 
  g_test_add_func ("/gvariant/constructors", test_constructors);
2443
3398
 
2444
3399
  for (i = 1; i <= 20; i += 4)
2445
3400
    {
2451
3406
      g_free (testname);
2452
3407
    }
2453
3408
 
 
3409
  g_test_add_func ("/gvariant/containers", test_containers);
 
3410
  g_test_add_func ("/gvariant/format-strings", test_format_strings);
 
3411
  g_test_add_func ("/gvariant/invalid-varargs", test_invalid_varargs);
 
3412
  g_test_add_func ("/gvariant/varargs", test_varargs);
 
3413
  g_test_add_func ("/gvariant/valist", test_valist);
 
3414
  g_test_add_func ("/gvariant/builder-memory", test_builder_memory);
 
3415
  g_test_add_func ("/gvariant/hashing", test_hashing);
 
3416
 
2454
3417
  return g_test_run ();
2455
3418
}