summaryrefstree
path: root/usr/share/gtk-doc/html/glib/glib-Testing.html
blob: 3a8ade676e4285ec788135ed50a223739ade6e84 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Testing</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-utilities.html" title="GLib Utilities">
<link rel="prev" href="glib-Bookmark-file-parser.html" title="Bookmark file parser">
<link rel="next" href="glib-UNIX-specific-utilities-and-integration.html" title="UNIX-specific utilities and integration">
<meta name="generator" content="GTK-Doc V1.19 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Bookmark-file-parser.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-UNIX-specific-utilities-and-integration.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#glib-Testing.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#glib-Testing.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="glib-Testing"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Testing.top_of_page"></a>Testing</span></h2>
<p>Testing — a test framework</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="glib-Testing.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;glib.h&gt;

<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-minimized-result" title="g_test_minimized_result ()">g_test_minimized_result</a>             (<em class="parameter"><code><span class="type">double</span> minimized_quantity</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *format</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-maximized-result" title="g_test_maximized_result ()">g_test_maximized_result</a>             (<em class="parameter"><code><span class="type">double</span> maximized_quantity</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *format</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()">g_test_init</a>                         (<em class="parameter"><code><span class="type">int</span> *argc</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> ***argv</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
#define             <a class="link" href="glib-Testing.html#g-test-initialized" title="g_test_initialized">g_test_initialized</a>
#define             <a class="link" href="glib-Testing.html#g-test-quick" title="g_test_quick">g_test_quick</a>
#define             <a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow">g_test_slow</a>
#define             <a class="link" href="glib-Testing.html#g-test-thorough" title="g_test_thorough">g_test_thorough</a>
#define             <a class="link" href="glib-Testing.html#g-test-perf" title="g_test_perf">g_test_perf</a>
#define             <a class="link" href="glib-Testing.html#g-test-verbose" title="g_test_verbose">g_test_verbose</a>
#define             <a class="link" href="glib-Testing.html#g-test-undefined" title="g_test_undefined">g_test_undefined</a>
#define             <a class="link" href="glib-Testing.html#g-test-quiet" title="g_test_quiet">g_test_quiet</a>
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Testing.html#g-test-subprocess" title="g_test_subprocess ()">g_test_subprocess</a>                   (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">int</span>                 <a class="link" href="glib-Testing.html#g-test-run" title="g_test_run ()">g_test_run</a>                          (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">void</span>                (<a class="link" href="glib-Testing.html#GTestFunc" title="GTestFunc ()">*GTestFunc</a>)                        (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-add-func" title="g_test_add_func ()">g_test_add_func</a>                     (<em class="parameter"><code>const <span class="type">char</span> *testpath</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFunc" title="GTestFunc ()"><span class="type">GTestFunc</span></a> test_func</code></em>);
<span class="returnvalue">void</span>                (<a class="link" href="glib-Testing.html#GTestDataFunc" title="GTestDataFunc ()">*GTestDataFunc</a>)                    (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> user_data</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-add-data-func" title="g_test_add_data_func ()">g_test_add_data_func</a>                (<em class="parameter"><code>const <span class="type">char</span> *testpath</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> test_data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestDataFunc" title="GTestDataFunc ()"><span class="type">GTestDataFunc</span></a> test_func</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-add-data-func-full" title="g_test_add_data_func_full ()">g_test_add_data_func_full</a>           (<em class="parameter"><code>const <span class="type">char</span> *testpath</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> test_data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestDataFunc" title="GTestDataFunc ()"><span class="type">GTestDataFunc</span></a> test_func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> data_free_func</code></em>);
#define             <a class="link" href="glib-Testing.html#g-test-add" title="g_test_add()">g_test_add</a>                          (testpath,
                                                         Fixture,
                                                         tdata,
                                                         fsetup,
                                                         ftest,
                                                         fteardown)
enum                <a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType">GTestFileType</a>;
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *             <a class="link" href="glib-Testing.html#g-test-build-filename" title="g_test_build_filename ()">g_test_build_filename</a>               (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a> file_type</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *first_path</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *       <a class="link" href="glib-Testing.html#g-test-get-filename" title="g_test_get_filename ()">g_test_get_filename</a>                 (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a> file_type</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *first_path</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *       <a class="link" href="glib-Testing.html#g-test-get-dir" title="g_test_get_dir ()">g_test_get_dir</a>                      (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a> file_type</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-fail" title="g_test_fail ()">g_test_fail</a>                         (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-message" title="g_test_message ()">g_test_message</a>                      (<em class="parameter"><code>const <span class="type">char</span> *format</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-bug-base" title="g_test_bug_base ()">g_test_bug_base</a>                     (<em class="parameter"><code>const <span class="type">char</span> *uri_pattern</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-bug" title="g_test_bug ()">g_test_bug</a>                          (<em class="parameter"><code>const <span class="type">char</span> *bug_uri_snippet</code></em>);
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            (<a class="link" href="glib-Testing.html#GTestLogFatalFunc" title="GTestLogFatalFunc ()">*GTestLogFatalFunc</a>)                (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *message</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-log-set-fatal-handler" title="g_test_log_set_fatal_handler ()">g_test_log_set_fatal_handler</a>        (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestLogFatalFunc" title="GTestLogFatalFunc ()"><span class="type">GTestLogFatalFunc</span></a> log_func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-timer-start" title="g_test_timer_start ()">g_test_timer_start</a>                  (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">double</span>              <a class="link" href="glib-Testing.html#g-test-timer-elapsed" title="g_test_timer_elapsed ()">g_test_timer_elapsed</a>                (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">double</span>              <a class="link" href="glib-Testing.html#g-test-timer-last" title="g_test_timer_last ()">g_test_timer_last</a>                   (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-queue-free" title="g_test_queue_free ()">g_test_queue_free</a>                   (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> gfree_pointer</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-queue-destroy" title="g_test_queue_destroy ()">g_test_queue_destroy</a>                (<em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> destroy_func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> destroy_data</code></em>);
#define             <a class="link" href="glib-Testing.html#g-test-queue-unref" title="g_test_queue_unref()">g_test_queue_unref</a>                  (gobject)
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-expect-message" title="g_test_expect_message ()">g_test_expect_message</a>               (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *pattern</code></em>);
#define             <a class="link" href="glib-Testing.html#g-test-assert-expected-messages" title="g_test_assert_expected_messages">g_test_assert_expected_messages</a>
enum                <a class="link" href="glib-Testing.html#GTestTrapFlags" title="enum GTestTrapFlags">GTestTrapFlags</a>;
enum                <a class="link" href="glib-Testing.html#GTestSubprocessFlags" title="enum GTestSubprocessFlags">GTestSubprocessFlags</a>;
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()">g_test_trap_subprocess</a>              (<em class="parameter"><code>const <span class="type">char</span> *test_path</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint64" title="guint64"><span class="type">guint64</span></a> usec_timeout</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSubprocessFlags" title="enum GTestSubprocessFlags"><span class="type">GTestSubprocessFlags</span></a> test_flags</code></em>);
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Testing.html#g-test-trap-has-passed" title="g_test_trap_has_passed ()">g_test_trap_has_passed</a>              (<em class="parameter"><code><span class="type">void</span></code></em>);
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Testing.html#g-test-trap-reached-timeout" title="g_test_trap_reached_timeout ()">g_test_trap_reached_timeout</a>         (<em class="parameter"><code><span class="type">void</span></code></em>);
#define             <a class="link" href="glib-Testing.html#g-test-trap-assert-passed" title="g_test_trap_assert_passed">g_test_trap_assert_passed</a>
#define             <a class="link" href="glib-Testing.html#g-test-trap-assert-failed" title="g_test_trap_assert_failed">g_test_trap_assert_failed</a>
#define             <a class="link" href="glib-Testing.html#g-test-trap-assert-stdout" title="g_test_trap_assert_stdout()">g_test_trap_assert_stdout</a>           (soutpattern)
#define             <a class="link" href="glib-Testing.html#g-test-trap-assert-stdout-unmatched" title="g_test_trap_assert_stdout_unmatched()">g_test_trap_assert_stdout_unmatched</a> (soutpattern)
#define             <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()">g_test_trap_assert_stderr</a>           (serrpattern)
#define             <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr-unmatched" title="g_test_trap_assert_stderr_unmatched()">g_test_trap_assert_stderr_unmatched</a> (serrpattern)
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Testing.html#g-test-trap-fork" title="g_test_trap_fork ()">g_test_trap_fork</a>                    (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint64" title="guint64"><span class="type">guint64</span></a> usec_timeout</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestTrapFlags" title="enum GTestTrapFlags"><span class="type">GTestTrapFlags</span></a> test_trap_flags</code></em>);
#define             <a class="link" href="glib-Testing.html#g-test-rand-bit" title="g_test_rand_bit">g_test_rand_bit</a>
<a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a>              <a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()">g_test_rand_int</a>                     (<em class="parameter"><code><span class="type">void</span></code></em>);
<a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a>              <a class="link" href="glib-Testing.html#g-test-rand-int-range" title="g_test_rand_int_range ()">g_test_rand_int_range</a>               (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="type">gint32</span></a> begin</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="type">gint32</span></a> end</code></em>);
<span class="returnvalue">double</span>              <a class="link" href="glib-Testing.html#g-test-rand-double" title="g_test_rand_double ()">g_test_rand_double</a>                  (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">double</span>              <a class="link" href="glib-Testing.html#g-test-rand-double-range" title="g_test_rand_double_range ()">g_test_rand_double_range</a>            (<em class="parameter"><code><span class="type">double</span> range_start</code></em>,
                                                         <em class="parameter"><code><span class="type">double</span> range_end</code></em>);
#define             <a class="link" href="glib-Testing.html#g-assert" title="g_assert()">g_assert</a>                            (expr)
#define             <a class="link" href="glib-Testing.html#g-assert-not-reached" title="g_assert_not_reached">g_assert_not_reached</a>
#define             <a class="link" href="glib-Testing.html#g-assert-cmpstr" title="g_assert_cmpstr()">g_assert_cmpstr</a>                     (s1,
                                                         cmp,
                                                         s2)
#define             <a class="link" href="glib-Testing.html#g-assert-cmpint" title="g_assert_cmpint()">g_assert_cmpint</a>                     (n1,
                                                         cmp,
                                                         n2)
#define             <a class="link" href="glib-Testing.html#g-assert-cmpuint" title="g_assert_cmpuint()">g_assert_cmpuint</a>                    (n1,
                                                         cmp,
                                                         n2)
#define             <a class="link" href="glib-Testing.html#g-assert-cmphex" title="g_assert_cmphex()">g_assert_cmphex</a>                     (n1,
                                                         cmp,
                                                         n2)
#define             <a class="link" href="glib-Testing.html#g-assert-cmpfloat" title="g_assert_cmpfloat()">g_assert_cmpfloat</a>                   (n1,
                                                         cmp,
                                                         n2)
#define             <a class="link" href="glib-Testing.html#g-assert-no-error" title="g_assert_no_error()">g_assert_no_error</a>                   (err)
#define             <a class="link" href="glib-Testing.html#g-assert-error" title="g_assert_error()">g_assert_error</a>                      (err,
                                                         dom,
                                                         c)
typedef             <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase">GTestCase</a>;
typedef             <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite">GTestSuite</a>;
<span class="returnvalue">void</span>                (<a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()">*GTestFixtureFunc</a>)                 (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> fixture</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> user_data</code></em>);
<a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="returnvalue">GTestCase</span></a> *         <a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()">g_test_create_case</a>                  (<em class="parameter"><code>const <span class="type">char</span> *test_name</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> data_size</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> test_data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()"><span class="type">GTestFixtureFunc</span></a> data_setup</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()"><span class="type">GTestFixtureFunc</span></a> data_test</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()"><span class="type">GTestFixtureFunc</span></a> data_teardown</code></em>);
<a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="returnvalue">GTestSuite</span></a> *        <a class="link" href="glib-Testing.html#g-test-create-suite" title="g_test_create_suite ()">g_test_create_suite</a>                 (<em class="parameter"><code>const <span class="type">char</span> *suite_name</code></em>);
<a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="returnvalue">GTestSuite</span></a> *        <a class="link" href="glib-Testing.html#g-test-get-root" title="g_test_get_root ()">g_test_get_root</a>                     (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-suite-add" title="g_test_suite_add ()">g_test_suite_add</a>                    (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *suite</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a> *test_case</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Testing.html#g-test-suite-add-suite" title="g_test_suite_add_suite ()">g_test_suite_add_suite</a>              (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *suite</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *nestedsuite</code></em>);
<span class="returnvalue">int</span>                 <a class="link" href="glib-Testing.html#g-test-run-suite" title="g_test_run_suite ()">g_test_run_suite</a>                    (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *suite</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="glib-Testing.description"></a><h2>Description</h2>
<p>
GLib provides a framework for writing and maintaining unit tests
in parallel to the code they are testing. The API is designed according
to established concepts found in the other test frameworks (JUnit, NUnit,
RUnit), which in turn is based on smalltalk unit testing concepts.
</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Test case</span></p></td>
<td>Tests (test methods) are grouped together with their
      fixture into test cases.</td>
</tr>
<tr>
<td><p><span class="term">Fixture</span></p></td>
<td>A test fixture consists of fixture data and setup and
      teardown methods to establish the environment for the test
      functions. We use fresh fixtures, i.e. fixtures are newly set
      up and torn down around each test invocation to avoid dependencies
      between tests.</td>
</tr>
<tr>
<td><p><span class="term">Test suite</span></p></td>
<td>Test cases can be grouped into test suites, to allow
      subsets of the available tests to be run. Test suites can be
      grouped into other test suites as well.</td>
</tr>
</tbody>
</table></div>
<p>
The API is designed to handle creation and registration of test suites
and test cases implicitly. A simple call like
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function"><a href="glib-Testing.html#g-test-add-func">g_test_add_func</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"/misc/assertions"</span><span class="symbol">,</span><span class="normal"> test_assertions</span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
creates a test suite called "misc" with a single test case named
"assertions", which consists of running the test_assertions function.
</p>
<p>
In addition to the traditional <a class="link" href="glib-Testing.html#g-assert" title="g_assert()"><code class="function">g_assert()</code></a>, the test framework provides
an extended set of assertions for string and numerical comparisons:
<a class="link" href="glib-Testing.html#g-assert-cmpfloat" title="g_assert_cmpfloat()"><code class="function">g_assert_cmpfloat()</code></a>, <a class="link" href="glib-Testing.html#g-assert-cmpint" title="g_assert_cmpint()"><code class="function">g_assert_cmpint()</code></a>, <a class="link" href="glib-Testing.html#g-assert-cmpuint" title="g_assert_cmpuint()"><code class="function">g_assert_cmpuint()</code></a>,
<a class="link" href="glib-Testing.html#g-assert-cmphex" title="g_assert_cmphex()"><code class="function">g_assert_cmphex()</code></a>, <a class="link" href="glib-Testing.html#g-assert-cmpstr" title="g_assert_cmpstr()"><code class="function">g_assert_cmpstr()</code></a>. The advantage of these variants
over plain <a class="link" href="glib-Testing.html#g-assert" title="g_assert()"><code class="function">g_assert()</code></a> is that the assertion messages can be more
elaborate, and include the values of the compared entities.
</p>
<p>
GLib ships with two utilities called gtester and gtester-report to
facilitate running tests and producing nicely formatted test reports.
</p>
</div>
<div class="refsect1">
<a name="glib-Testing.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="g-test-minimized-result"></a><h3>g_test_minimized_result ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_minimized_result             (<em class="parameter"><code><span class="type">double</span> minimized_quantity</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *format</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Report the result of a performance or measurement test.
The test should generally strive to minimize the reported
quantities (smaller values are better than larger ones),
this and <em class="parameter"><code>minimized_quantity</code></em> can determine sorting
order for test result reports.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>minimized_quantity</code></em> :</span></p></td>
<td>the reported value</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td>
<td>the format string of the report message</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>arguments to pass to the <code class="function">printf()</code> function</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-maximized-result"></a><h3>g_test_maximized_result ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_maximized_result             (<em class="parameter"><code><span class="type">double</span> maximized_quantity</code></em>,
                                                         <em class="parameter"><code>const <span class="type">char</span> *format</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Report the result of a performance or measurement test.
The test should generally strive to maximize the reported
quantities (larger values are better than smaller ones),
this and <em class="parameter"><code>maximized_quantity</code></em> can determine sorting
order for test result reports.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>maximized_quantity</code></em> :</span></p></td>
<td>the reported value</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td>
<td>the format string of the report message</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>arguments to pass to the <code class="function">printf()</code> function</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-init"></a><h3>g_test_init ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_init                         (<em class="parameter"><code><span class="type">int</span> *argc</code></em>,
                                                         <em class="parameter"><code><span class="type">char</span> ***argv</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Initialize the GLib testing framework, e.g. by seeding the
test random number generator, the name for <a class="link" href="glib-Miscellaneous-Utility-Functions.html#g-get-prgname" title="g_get_prgname ()"><code class="function">g_get_prgname()</code></a>
and parsing test related command line args.
So far, the following arguments are understood:
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="option">-l</code></span></p></td>
<td><p>
      List test cases available in a test executable.
    </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--seed=<em class="replaceable"><code>RANDOMSEED</code></em></code></span></p></td>
<td><p>
      Provide a random seed to reproduce test runs using random numbers.
    </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--verbose</code></span></p></td>
<td><p>Run tests verbosely.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">-q</code>, <code class="option">--quiet</code></span></p></td>
<td><p>Run tests quietly.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">-p <em class="replaceable"><code>TESTPATH</code></em></code></span></p></td>
<td><p>
        Execute all tests matching <em class="replaceable"><code>TESTPATH</code></em>.
        This can also be used to force a test to run that would otherwise
        be skipped (ie, a test whose name contains "/subprocess").
      </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="option">-m {perf|slow|thorough|quick|undefined|no-undefined}</code></span></p></td>
<td>
<p>
        Execute tests according to these test modes:
        </p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">perf</span></p></td>
<td><p>
              Performance tests, may take long and report results.
            </p></td>
</tr>
<tr>
<td><p><span class="term">slow, thorough</span></p></td>
<td><p>
              Slow and thorough tests, may take quite long and
              maximize coverage.
            </p></td>
</tr>
<tr>
<td><p><span class="term">quick</span></p></td>
<td><p>
              Quick tests, should run really quickly and give good coverage.
            </p></td>
</tr>
<tr>
<td><p><span class="term">undefined</span></p></td>
<td><p>
              Tests for undefined behaviour, may provoke programming errors
              under <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> or <a href="glib-Testing.html#g-test-expect-message"><code class="function">g_test_expect_messages()</code></a> to check
              that appropriate assertions or warnings are given
            </p></td>
</tr>
<tr>
<td><p><span class="term">no-undefined</span></p></td>
<td><p>
              Avoid tests for undefined behaviour
            </p></td>
</tr>
</tbody>
</table></div>
<p>
      </p>
</td>
</tr>
<tr>
<td><p><span class="term"><code class="option">--debug-log</code></span></p></td>
<td><p>Debug test logging output.</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>argc</code></em> :</span></p></td>
<td>Address of the <em class="parameter"><code>argc</code></em> parameter of the <code class="function">main()</code> function.
Changed if any arguments were handled.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>argv</code></em> :</span></p></td>
<td>Address of the <em class="parameter"><code>argv</code></em> parameter of <code class="function">main()</code>.
Any parameters understood by <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a> stripped before return.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>Reserved for future extension. Currently, you must pass <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-initialized"></a><h3>g_test_initialized</h3>
<pre class="programlisting">#define             g_test_initialized()</pre>
<p>
Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a> has been called.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a> has been called.</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.36</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-quick"></a><h3>g_test_quick</h3>
<pre class="programlisting">#define             g_test_quick()</pre>
<p>
Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in quick mode.
Exactly one of <a class="link" href="glib-Testing.html#g-test-quick" title="g_test_quick"><code class="function">g_test_quick()</code></a> and <a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow"><code class="function">g_test_slow()</code></a> is active in any run;
there is no "medium speed".
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if in quick mode</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-slow"></a><h3>g_test_slow</h3>
<pre class="programlisting">#define             g_test_slow()</pre>
<p>
Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in slow mode.
Exactly one of <a class="link" href="glib-Testing.html#g-test-quick" title="g_test_quick"><code class="function">g_test_quick()</code></a> and <a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow"><code class="function">g_test_slow()</code></a> is active in any run;
there is no "medium speed".
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the opposite of <a class="link" href="glib-Testing.html#g-test-quick" title="g_test_quick"><code class="function">g_test_quick()</code></a>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-thorough"></a><h3>g_test_thorough</h3>
<pre class="programlisting">#define             g_test_thorough()</pre>
<p>
Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in thorough mode, equivalent to
<a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow"><code class="function">g_test_slow()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the same thing as <a class="link" href="glib-Testing.html#g-test-slow" title="g_test_slow"><code class="function">g_test_slow()</code></a>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-perf"></a><h3>g_test_perf</h3>
<pre class="programlisting">#define             g_test_perf()</pre>
<p>
Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in performance mode.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if in performance mode</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-verbose"></a><h3>g_test_verbose</h3>
<pre class="programlisting">#define             g_test_verbose()</pre>
<p>
Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in verbose mode.
The default is neither <a class="link" href="glib-Testing.html#g-test-verbose" title="g_test_verbose"><code class="function">g_test_verbose()</code></a> nor <a class="link" href="glib-Testing.html#g-test-quiet" title="g_test_quiet"><code class="function">g_test_quiet()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if in verbose mode</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-undefined"></a><h3>g_test_undefined</h3>
<pre class="programlisting">#define             g_test_undefined()</pre>
<p>
Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests may provoke assertions and other formally-undefined
behaviour, to verify that appropriate warnings are given. It might, in some
cases, be useful to turn this off if running tests under valgrind.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests may provoke programming errors</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-quiet"></a><h3>g_test_quiet</h3>
<pre class="programlisting">#define             g_test_quiet()</pre>
<p>
Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if tests are run in quiet mode.
The default is neither <a class="link" href="glib-Testing.html#g-test-verbose" title="g_test_verbose"><code class="function">g_test_verbose()</code></a> nor <a class="link" href="glib-Testing.html#g-test-quiet" title="g_test_quiet"><code class="function">g_test_quiet()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if in quiet mode</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-subprocess"></a><h3>g_test_subprocess ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_test_subprocess                   (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> (after <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a> has been called) if the test
program is running under <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the test program is running under
<a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.38</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-run"></a><h3>g_test_run ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span>                 g_test_run                          (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Runs all tests under the toplevel suite which can be retrieved
with <a class="link" href="glib-Testing.html#g-test-get-root" title="g_test_get_root ()"><code class="function">g_test_get_root()</code></a>. Similar to <a class="link" href="glib-Testing.html#g-test-run-suite" title="g_test_run_suite ()"><code class="function">g_test_run_suite()</code></a>, the test
cases to be run are filtered according to
test path arguments (-p <em class="replaceable"><code>testpath</code></em>) as 
parsed by <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a>.
<a class="link" href="glib-Testing.html#g-test-run-suite" title="g_test_run_suite ()"><code class="function">g_test_run_suite()</code></a> or <a class="link" href="glib-Testing.html#g-test-run" title="g_test_run ()"><code class="function">g_test_run()</code></a> may only be called once
in a program.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="GTestFunc"></a><h3>GTestFunc ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                (*GTestFunc)                        (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
The type used for test case functions.
</p>
<p class="since">Since 2.28</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-add-func"></a><h3>g_test_add_func ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_add_func                     (<em class="parameter"><code>const <span class="type">char</span> *testpath</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFunc" title="GTestFunc ()"><span class="type">GTestFunc</span></a> test_func</code></em>);</pre>
<p>
Create a new test case, similar to <a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()"><code class="function">g_test_create_case()</code></a>. However
the test is assumed to use no fixture, and test suites are automatically
created on the fly and added to the root fixture, based on the
slash-separated portions of <em class="parameter"><code>testpath</code></em>.
</p>
<p>
If <em class="parameter"><code>testpath</code></em> includes the component "subprocess" anywhere in it,
the test will be skipped by default, and only run if explicitly
required via the <code class="option">-p</code> command-line option or
<a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>testpath</code></em> :</span></p></td>
<td>/-separated test case path name for the test.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_func</code></em> :</span></p></td>
<td>The test function to invoke for this test.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="GTestDataFunc"></a><h3>GTestDataFunc ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                (*GTestDataFunc)                    (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> user_data</code></em>);</pre>
<p>
The type used for test case functions that take an extra pointer
argument.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>the data provided when registering the test</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.28</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-add-data-func"></a><h3>g_test_add_data_func ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_add_data_func                (<em class="parameter"><code>const <span class="type">char</span> *testpath</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> test_data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestDataFunc" title="GTestDataFunc ()"><span class="type">GTestDataFunc</span></a> test_func</code></em>);</pre>
<p>
Create a new test case, similar to <a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()"><code class="function">g_test_create_case()</code></a>. However
the test is assumed to use no fixture, and test suites are automatically
created on the fly and added to the root fixture, based on the
slash-separated portions of <em class="parameter"><code>testpath</code></em>. The <em class="parameter"><code>test_data</code></em> argument
will be passed as first argument to <em class="parameter"><code>test_func</code></em>.
</p>
<p>
If <em class="parameter"><code>testpath</code></em> includes the component "subprocess" anywhere in it,
the test will be skipped by default, and only run if explicitly
required via the <code class="option">-p</code> command-line option or
<a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>testpath</code></em> :</span></p></td>
<td>/-separated test case path name for the test.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_data</code></em> :</span></p></td>
<td>Test data argument for the test function.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_func</code></em> :</span></p></td>
<td>The test function to invoke for this test.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-add-data-func-full"></a><h3>g_test_add_data_func_full ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_add_data_func_full           (<em class="parameter"><code>const <span class="type">char</span> *testpath</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> test_data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestDataFunc" title="GTestDataFunc ()"><span class="type">GTestDataFunc</span></a> test_func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> data_free_func</code></em>);</pre>
<p>
Create a new test case, as with <a class="link" href="glib-Testing.html#g-test-add-data-func" title="g_test_add_data_func ()"><code class="function">g_test_add_data_func()</code></a>, but freeing
<em class="parameter"><code>test_data</code></em> after the test run is complete.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>testpath</code></em> :</span></p></td>
<td>/-separated test case path name for the test.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_data</code></em> :</span></p></td>
<td>Test data argument for the test function.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_func</code></em> :</span></p></td>
<td>The test function to invoke for this test.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data_free_func</code></em> :</span></p></td>
<td>
<a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> for <em class="parameter"><code>test_data</code></em>.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.34</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-add"></a><h3>g_test_add()</h3>
<pre class="programlisting">#define             g_test_add(testpath, Fixture, tdata, fsetup, ftest, fteardown)</pre>
<p>
Hook up a new test case at <em class="parameter"><code>testpath</code></em>, similar to <a class="link" href="glib-Testing.html#g-test-add-func" title="g_test_add_func ()"><code class="function">g_test_add_func()</code></a>.
A fixture data structure with setup and teardown function may be provided
though, similar to <a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()"><code class="function">g_test_create_case()</code></a>.
<a class="link" href="glib-Testing.html#g-test-add" title="g_test_add()"><code class="function">g_test_add()</code></a> is implemented as a macro, so that the <code class="function">fsetup()</code>, <code class="function">ftest()</code> and
<code class="function">fteardown()</code> callbacks can expect a <em class="parameter"><code>Fixture</code></em> pointer as first argument in
a type safe manner.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>testpath</code></em> :</span></p></td>
<td>The test path for a new test case.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>Fixture</code></em> :</span></p></td>
<td>The type of a fixture data structure.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>tdata</code></em> :</span></p></td>
<td>Data argument for the test functions.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>fsetup</code></em> :</span></p></td>
<td>The function to set up the fixture data.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>ftest</code></em> :</span></p></td>
<td>The actual test function.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>fteardown</code></em> :</span></p></td>
<td>The function to tear down the fixture data.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="GTestFileType"></a><h3>enum GTestFileType</h3>
<pre class="programlisting">typedef enum {
  G_TEST_DIST,
  G_TEST_BUILT
} GTestFileType;
</pre>
<p>
The type of file to return the filename for, when used with
<a class="link" href="glib-Testing.html#g-test-build-filename" title="g_test_build_filename ()"><code class="function">g_test_build_filename()</code></a>.
</p>
<p>
These two options correspond rather directly to the 'dist' and
'built' terminology that automake uses and are explicitly used to
distinguish between the 'srcdir' and 'builddir' being separate.  All
files in your project should either be dist (in the
<code class="literal">DIST_EXTRA</code> or <code class="literal">dist_schema_DATA</code>
sense, in which case they will always be in the srcdir) or built (in
the <code class="literal">BUILT_SOURCES</code> sense, in which case they will
always be in the builddir).
</p>
<p>
Note: as a general rule of automake, files that are generated only as
part of the build-from-git process (but then are distributed with the
tarball) always go in srcdir (even if doing a srcdir != builddir
build from git) and are considered as distributed files.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><a name="G-TEST-DIST:CAPS"></a><span class="term"><code class="literal">G_TEST_DIST</code></span></p></td>
<td>a file that was included in the distribution tarball
</td>
</tr>
<tr>
<td><p><a name="G-TEST-BUILT:CAPS"></a><span class="term"><code class="literal">G_TEST_BUILT</code></span></p></td>
<td>a file that was built on the compiling machine
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.38</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-build-filename"></a><h3>g_test_build_filename ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *             g_test_build_filename               (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a> file_type</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *first_path</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Creates the pathname to a data file that is required for a test.
</p>
<p>
This function is conceptually similar to <a class="link" href="glib-Miscellaneous-Utility-Functions.html#g-build-filename" title="g_build_filename ()"><code class="function">g_build_filename()</code></a> except
that the first argument has been replaced with a <a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a>
argument.
</p>
<p>
The data file should either have been distributed with the module
containing the test (<a class="link" href="glib-Testing.html#G-TEST-DIST:CAPS"><code class="literal">G_TEST_DIST</code></a>) or built as part of the build
system of that module (<a class="link" href="glib-Testing.html#G-TEST-BUILT:CAPS"><code class="literal">G_TEST_BUILT</code></a>).
</p>
<p>
In order for this function to work in srcdir != builddir situations,
the G_TEST_SRCDIR and G_TEST_BUILDDIR environment variables need to
have been defined.  As of 2.38, this is done by the Makefile.decl
included in GLib.  Please ensure that your copy is up to date before
using this function.
</p>
<p>
In case neither variable is set, this function will fall back to
using the dirname portion of argv[0], possibly removing ".libs".
This allows for casual running of tests directly from the commandline
in the srcdir == builddir case and should also support running of
installed tests, assuming the data files have been installed in the
same relative path as the test binary.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>file_type</code></em> :</span></p></td>
<td>the type of file (built vs. distributed)</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>first_path</code></em> :</span></p></td>
<td>the first segment of the pathname</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>-terminated additional path segments</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the path of the file, to be freed using <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.38</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-get-filename"></a><h3>g_test_get_filename ()</h3>
<pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *       g_test_get_filename                 (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a> file_type</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *first_path</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Gets the pathname to a data file that is required for a test.
</p>
<p>
This is the same as <a class="link" href="glib-Testing.html#g-test-build-filename" title="g_test_build_filename ()"><code class="function">g_test_build_filename()</code></a> with two differences.
The first difference is that must only use this function from within
a testcase function.  The second difference is that you need not free
the return value -- it will be automatically freed when the testcase
finishes running.
</p>
<p>
It is safe to use this function from a thread inside of a testcase
but you must ensure that all such uses occur before the main testcase
function returns (ie: it is best to ensure that all threads have been
joined).
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>file_type</code></em> :</span></p></td>
<td>the type of file (built vs. distributed)</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>first_path</code></em> :</span></p></td>
<td>the first segment of the pathname</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>-terminated additional path segments</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the path, automatically freed at the end of the testcase</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.38</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-get-dir"></a><h3>g_test_get_dir ()</h3>
<pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *       g_test_get_dir                      (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFileType" title="enum GTestFileType"><span class="type">GTestFileType</span></a> file_type</code></em>);</pre>
<p>
Gets the pathname of the directory containing test files of the type
specified by <em class="parameter"><code>file_type</code></em>.
</p>
<p>
This is approximately the same as calling g_test_build_filename("."),
but you don't need to free the return value.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>file_type</code></em> :</span></p></td>
<td>the type of file (built vs. distributed)</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the path of the directory, owned by GLib</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.38</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-fail"></a><h3>g_test_fail ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_fail                         (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Indicates that a test failed. This function can be called
multiple times from the same test. You can use this function
if your test failed in a recoverable way.
</p>
<p>
Do not use this function if the failure of a test could cause
other tests to malfunction.
</p>
<p>
Calling this function will not stop the test from running, you
need to return from the test function yourself. So you can
produce additional diagnostic messages or even continue running
the test.
</p>
<p>
If not called from inside a test, this function does nothing.
</p>
<p class="since">Since 2.30</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-message"></a><h3>g_test_message ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_message                      (<em class="parameter"><code>const <span class="type">char</span> *format</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Add a message to the test report.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td>
<td>the format string</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>printf-like arguments to <em class="parameter"><code>format</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-bug-base"></a><h3>g_test_bug_base ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_bug_base                     (<em class="parameter"><code>const <span class="type">char</span> *uri_pattern</code></em>);</pre>
<p>
Specify the base URI for bug reports.
</p>
<p>
The base URI is used to construct bug report messages for
<a class="link" href="glib-Testing.html#g-test-message" title="g_test_message ()"><code class="function">g_test_message()</code></a> when <a class="link" href="glib-Testing.html#g-test-bug" title="g_test_bug ()"><code class="function">g_test_bug()</code></a> is called.
Calling this function outside of a test case sets the
default base URI for all test cases. Calling it from within
a test case changes the base URI for the scope of the test
case only.
Bug URIs are constructed by appending a bug specific URI
portion to <em class="parameter"><code>uri_pattern</code></em>, or by replacing the special string
'%s' within <em class="parameter"><code>uri_pattern</code></em> if that is present.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>uri_pattern</code></em> :</span></p></td>
<td>the base pattern for bug URIs</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-bug"></a><h3>g_test_bug ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_bug                          (<em class="parameter"><code>const <span class="type">char</span> *bug_uri_snippet</code></em>);</pre>
<p>
This function adds a message to test reports that
associates a bug URI with a test case.
Bug URIs are constructed from a base URI set with <a class="link" href="glib-Testing.html#g-test-bug-base" title="g_test_bug_base ()"><code class="function">g_test_bug_base()</code></a>
and <em class="parameter"><code>bug_uri_snippet</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>bug_uri_snippet</code></em> :</span></p></td>
<td>Bug specific bug tracker URI portion.</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="GTestLogFatalFunc"></a><h3>GTestLogFatalFunc ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            (*GTestLogFatalFunc)                (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *message</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>
Specifies the prototype of fatal log handler functions.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>log_domain</code></em> :</span></p></td>
<td>the log domain of the message</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>log_level</code></em> :</span></p></td>
<td>the log level of the message (including the fatal and recursion flags)</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>message</code></em> :</span></p></td>
<td>the message to process</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>user data, set in <a class="link" href="glib-Testing.html#g-test-log-set-fatal-handler" title="g_test_log_set_fatal_handler ()"><code class="function">g_test_log_set_fatal_handler()</code></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the program should abort, <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> otherwise</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-log-set-fatal-handler"></a><h3>g_test_log_set_fatal_handler ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_log_set_fatal_handler        (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestLogFatalFunc" title="GTestLogFatalFunc ()"><span class="type">GTestLogFatalFunc</span></a> log_func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>
Installs a non-error fatal log handler which can be
used to decide whether log messages which are counted
as fatal abort the program.
</p>
<p>
The use case here is that you are running a test case
that depends on particular libraries or circumstances
and cannot prevent certain known critical or warning
messages. So you install a handler that compares the
domain and message to precisely not abort in such a case.
</p>
<p>
Note that the handler is reset at the beginning of
any test case, so you have to set it inside each test
function which needs the special behavior.
</p>
<p>
This handler has no effect on g_error messages.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>log_func</code></em> :</span></p></td>
<td>the log handler function.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>data passed to the log handler.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-timer-start"></a><h3>g_test_timer_start ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_timer_start                  (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Start a timing test. Call <a class="link" href="glib-Testing.html#g-test-timer-elapsed" title="g_test_timer_elapsed ()"><code class="function">g_test_timer_elapsed()</code></a> when the task is supposed
to be done. Call this function again to restart the timer.
</p>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-timer-elapsed"></a><h3>g_test_timer_elapsed ()</h3>
<pre class="programlisting"><span class="returnvalue">double</span>              g_test_timer_elapsed                (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Get the time since the last start of the timer with <a class="link" href="glib-Testing.html#g-test-timer-start" title="g_test_timer_start ()"><code class="function">g_test_timer_start()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the time since the last start of the timer, as a double</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-timer-last"></a><h3>g_test_timer_last ()</h3>
<pre class="programlisting"><span class="returnvalue">double</span>              g_test_timer_last                   (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Report the last result of <a class="link" href="glib-Testing.html#g-test-timer-elapsed" title="g_test_timer_elapsed ()"><code class="function">g_test_timer_elapsed()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the last result of <a class="link" href="glib-Testing.html#g-test-timer-elapsed" title="g_test_timer_elapsed ()"><code class="function">g_test_timer_elapsed()</code></a>, as a double</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-queue-free"></a><h3>g_test_queue_free ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_queue_free                   (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> gfree_pointer</code></em>);</pre>
<p>
Enqueue a pointer to be released with <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a> during the next
teardown phase. This is equivalent to calling <a class="link" href="glib-Testing.html#g-test-queue-destroy" title="g_test_queue_destroy ()"><code class="function">g_test_queue_destroy()</code></a>
with a destroy callback of <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>gfree_pointer</code></em> :</span></p></td>
<td>the pointer to be stored.</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-queue-destroy"></a><h3>g_test_queue_destroy ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_queue_destroy                (<em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> destroy_func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> destroy_data</code></em>);</pre>
<p>
This function enqueus a callback <em class="parameter"><code>destroy_func</code></em> to be executed
during the next test case teardown phase. This is most useful
to auto destruct allocted test resources at the end of a test run.
Resources are released in reverse queue order, that means enqueueing
callback A before callback B will cause <code class="function">B()</code> to be called before
<code class="function">A()</code> during teardown.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>destroy_func</code></em> :</span></p></td>
<td>Destroy callback for teardown phase.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>destroy_data</code></em> :</span></p></td>
<td>Destroy callback data.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-queue-unref"></a><h3>g_test_queue_unref()</h3>
<pre class="programlisting">#define             g_test_queue_unref(gobject)</pre>
<p>
Enqueue an object to be released with <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a> during
the next teardown phase. This is equivalent to calling
<a class="link" href="glib-Testing.html#g-test-queue-destroy" title="g_test_queue_destroy ()"><code class="function">g_test_queue_destroy()</code></a> with a destroy callback of <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>gobject</code></em> :</span></p></td>
<td>the object to unref</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-expect-message"></a><h3>g_test_expect_message ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_expect_message               (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *pattern</code></em>);</pre>
<p>
Indicates that a message with the given <em class="parameter"><code>log_domain</code></em> and <em class="parameter"><code>log_level</code></em>,
with text matching <em class="parameter"><code>pattern</code></em>, is expected to be logged. When this
message is logged, it will not be printed, and the test case will
not abort.
</p>
<p>
Use <a class="link" href="glib-Testing.html#g-test-assert-expected-messages" title="g_test_assert_expected_messages"><code class="function">g_test_assert_expected_messages()</code></a> to assert that all
previously-expected messages have been seen and suppressed.
</p>
<p>
You can call this multiple times in a row, if multiple messages are
expected as a result of a single call. (The messages must appear in
the same order as the calls to <a class="link" href="glib-Testing.html#g-test-expect-message" title="g_test_expect_message ()"><code class="function">g_test_expect_message()</code></a>.)
</p>
<p>
For example:
</p>
<p>
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="comment">/* g_main_context_push_thread_default() should fail if the</span>
<span class="comment"> * context is already owned by another thread.</span>
<span class="comment"> */</span>
<span class="function"><a href="glib-Testing.html#g-test-expect-message">g_test_expect_message</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Message-Logging.html#G-LOG-DOMAIN:CAPS">G_LOG_DOMAIN</a></span><span class="symbol">,</span>
<span class="normal">                       <a href="glib-Message-Logging.html#G-LOG-LEVEL-CRITICAL:CAPS">G_LOG_LEVEL_CRITICAL</a></span><span class="symbol">,</span>
<span class="normal">                       </span><span class="string">"assertion*acquired_context*failed"</span><span class="symbol">);</span>
<span class="function"><a href="glib-The-Main-Event-Loop.html#g-main-context-push-thread-default">g_main_context_push_thread_default</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">bad_context</span><span class="symbol">);</span>
<span class="function"><a href="glib-Testing.html#g-test-assert-expected-messages">g_test_assert_expected_messages</a></span><span class="normal"> </span><span class="symbol">();</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
</p>
<p>
Note that you cannot use this to test <a class="link" href="glib-Message-Logging.html#g-error" title="g_error()"><code class="function">g_error()</code></a> messages, since
<a class="link" href="glib-Message-Logging.html#g-error" title="g_error()"><code class="function">g_error()</code></a> intentionally never returns even if the program doesn't
abort; use <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> in this case.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>log_domain</code></em> :</span></p></td>
<td>the log domain of the message. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>log_level</code></em> :</span></p></td>
<td>the log level of the message</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>pattern</code></em> :</span></p></td>
<td>a glob-style
<a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.34</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-assert-expected-messages"></a><h3>g_test_assert_expected_messages</h3>
<pre class="programlisting">#define             g_test_assert_expected_messages()</pre>
<p>
Asserts that all messages previously indicated via
<a class="link" href="glib-Testing.html#g-test-expect-message" title="g_test_expect_message ()"><code class="function">g_test_expect_message()</code></a> have been seen and suppressed.
</p>
<p class="since">Since 2.34</p>
</div>
<hr>
<div class="refsect2">
<a name="GTestTrapFlags"></a><h3>enum GTestTrapFlags</h3>
<pre class="programlisting">typedef enum {
  G_TEST_TRAP_SILENCE_STDOUT    = 1 &lt;&lt; 7,
  G_TEST_TRAP_SILENCE_STDERR    = 1 &lt;&lt; 8,
  G_TEST_TRAP_INHERIT_STDIN     = 1 &lt;&lt; 9
} GTestTrapFlags;
</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">GTestTrapFlags</code> is deprecated and should not be used in newly-written code. <a class="link" href="glib-Testing.html#GTestTrapFlags" title="enum GTestTrapFlags"><span class="type">GTestTrapFlags</span></a> is used only with <a class="link" href="glib-Testing.html#g-test-trap-fork" title="g_test_trap_fork ()"><code class="function">g_test_trap_fork()</code></a>,
which is deprecated. <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> uses
<span class="type">GTestTrapSubprocessFlags</span>.</p>
</div>
<p>
Test traps are guards around forked tests.
These flags determine what traps to set.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><a name="G-TEST-TRAP-SILENCE-STDOUT:CAPS"></a><span class="term"><code class="literal">G_TEST_TRAP_SILENCE_STDOUT</code></span></p></td>
<td>Redirect stdout of the test child to
    <code class="filename">/dev/null</code> so it cannot be observed on the
    console during test runs. The actual output is still captured
    though to allow later tests with <a class="link" href="glib-Testing.html#g-test-trap-assert-stdout" title="g_test_trap_assert_stdout()"><code class="function">g_test_trap_assert_stdout()</code></a>.
</td>
</tr>
<tr>
<td><p><a name="G-TEST-TRAP-SILENCE-STDERR:CAPS"></a><span class="term"><code class="literal">G_TEST_TRAP_SILENCE_STDERR</code></span></p></td>
<td>Redirect stderr of the test child to
    <code class="filename">/dev/null</code> so it cannot be observed on the
    console during test runs. The actual output is still captured
    though to allow later tests with <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()"><code class="function">g_test_trap_assert_stderr()</code></a>.
</td>
</tr>
<tr>
<td><p><a name="G-TEST-TRAP-INHERIT-STDIN:CAPS"></a><span class="term"><code class="literal">G_TEST_TRAP_INHERIT_STDIN</code></span></p></td>
<td>If this flag is given, stdin of the
    child process is shared with stdin of its parent process.
    It is redirected to <code class="filename">/dev/null</code> otherwise.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="GTestSubprocessFlags"></a><h3>enum GTestSubprocessFlags</h3>
<pre class="programlisting">typedef enum {
  G_TEST_SUBPROCESS_INHERIT_STDIN  = 1 &lt;&lt; 0,
  G_TEST_SUBPROCESS_INHERIT_STDOUT = 1 &lt;&lt; 1,
  G_TEST_SUBPROCESS_INHERIT_STDERR = 1 &lt;&lt; 2
} GTestSubprocessFlags;
</pre>
<p>
Flags to pass to <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> to control input and output.
</p>
<p>
Note that in contrast with <a class="link" href="glib-Testing.html#g-test-trap-fork" title="g_test_trap_fork ()"><code class="function">g_test_trap_fork()</code></a>, the default is to
not show stdout and stderr.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><a name="G-TEST-SUBPROCESS-INHERIT-STDIN:CAPS"></a><span class="term"><code class="literal">G_TEST_SUBPROCESS_INHERIT_STDIN</code></span></p></td>
<td>If this flag is given, the child
    process will inherit the parent's stdin. Otherwise, the child's
    stdin is redirected to <code class="filename">/dev/null</code>.
</td>
</tr>
<tr>
<td><p><a name="G-TEST-SUBPROCESS-INHERIT-STDOUT:CAPS"></a><span class="term"><code class="literal">G_TEST_SUBPROCESS_INHERIT_STDOUT</code></span></p></td>
<td>If this flag is given, the child
    process will inherit the parent's stdout. Otherwise, the child's
    stdout will not be visible, but it will be captured to allow
    later tests with <a class="link" href="glib-Testing.html#g-test-trap-assert-stdout" title="g_test_trap_assert_stdout()"><code class="function">g_test_trap_assert_stdout()</code></a>.
</td>
</tr>
<tr>
<td><p><a name="G-TEST-SUBPROCESS-INHERIT-STDERR:CAPS"></a><span class="term"><code class="literal">G_TEST_SUBPROCESS_INHERIT_STDERR</code></span></p></td>
<td>If this flag is given, the child
    process will inherit the parent's stderr. Otherwise, the child's
    stderr will not be visible, but it will be captured to allow
    later tests with <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()"><code class="function">g_test_trap_assert_stderr()</code></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-subprocess"></a><h3>g_test_trap_subprocess ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_trap_subprocess              (<em class="parameter"><code>const <span class="type">char</span> *test_path</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint64" title="guint64"><span class="type">guint64</span></a> usec_timeout</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSubprocessFlags" title="enum GTestSubprocessFlags"><span class="type">GTestSubprocessFlags</span></a> test_flags</code></em>);</pre>
<p>
Respawns the test program to run only <em class="parameter"><code>test_path</code></em> in a subprocess.
This can be used for a test case that might not return, or that
might abort. <em class="parameter"><code>test_path</code></em> will normally be the name of the parent
test, followed by "<code class="literal">/subprocess/</code>" and then a name
for the specific subtest (or just ending with
"<code class="literal">/subprocess</code>" if the test only has one child
test); tests with names of this form will automatically be skipped
in the parent process.
</p>
<p>
If <em class="parameter"><code>usec_timeout</code></em> is non-0, the test subprocess is aborted and
considered failing if its run time exceeds it.
</p>
<p>
The subprocess behavior can be configured with the
<a class="link" href="glib-Testing.html#GTestSubprocessFlags" title="enum GTestSubprocessFlags"><span class="type">GTestSubprocessFlags</span></a> flags.
</p>
<p>
You can use methods such as <a class="link" href="glib-Testing.html#g-test-trap-assert-passed" title="g_test_trap_assert_passed"><code class="function">g_test_trap_assert_passed()</code></a>,
<a class="link" href="glib-Testing.html#g-test-trap-assert-failed" title="g_test_trap_assert_failed"><code class="function">g_test_trap_assert_failed()</code></a>, and <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()"><code class="function">g_test_trap_assert_stderr()</code></a> to
check the results of the subprocess. (But note that
<a class="link" href="glib-Testing.html#g-test-trap-assert-stdout" title="g_test_trap_assert_stdout()"><code class="function">g_test_trap_assert_stdout()</code></a> and <a class="link" href="glib-Testing.html#g-test-trap-assert-stderr" title="g_test_trap_assert_stderr()"><code class="function">g_test_trap_assert_stderr()</code></a>
cannot be used if <em class="parameter"><code>test_flags</code></em> specifies that the child should
inherit the parent stdout/stderr.) 
</p>
<p>
If your <code class="literal"><code class="function">main()</code></code> needs to behave differently in
the subprocess, you can call <a class="link" href="glib-Testing.html#g-test-subprocess" title="g_test_subprocess ()"><code class="function">g_test_subprocess()</code></a> (after calling
<a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a>) to see whether you are in a subprocess.
</p>
<p>
The following example tests that calling
<code class="literal">my_object_new(1000000)</code> will abort with an error
message.
</p>
<p>
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>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</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">test_create_large_object_subprocess</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">  </span><span class="function">my_object_new</span><span class="normal"> </span><span class="symbol">(</span><span class="number">1000000</span><span class="symbol">);</span>
<span class="cbracket">}</span>

<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">test_create_large_object</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">  </span><span class="function"><a href="glib-Testing.html#g-test-trap-subprocess">g_test_trap_subprocess</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"/myobject/create_large_object/subprocess"</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">);</span>
<span class="normal">  </span><span class="function"><a href="glib-Testing.html#g-test-trap-assert-failed">g_test_trap_assert_failed</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal">  </span><span class="function"><a href="glib-Testing.html#g-test-trap-assert-stderr">g_test_trap_assert_stderr</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"*ERROR*too large*"</span><span class="symbol">);</span>
<span class="cbracket">}</span>

<span class="type">int</span>
<span class="function">main</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> argc</span><span class="symbol">,</span><span class="normal"> </span><span class="type">char</span><span class="normal"> </span><span class="symbol">**</span><span class="normal">argv</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">  </span><span class="function"><a href="glib-Testing.html#g-test-init">g_test_init</a></span><span class="normal"> </span><span class="symbol">(&amp;</span><span class="normal">argc</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&amp;</span><span class="normal">argv</span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span>

<span class="normal">  </span><span class="function"><a href="glib-Testing.html#g-test-add-func">g_test_add_func</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"/myobject/create_large_object"</span><span class="symbol">,</span>
<span class="normal">                   test_create_large_object</span><span class="symbol">);</span>
<span class="normal">  </span><span class="comment">/* Because of the '/subprocess' in the name, this test will</span>
<span class="comment">   * not be run by the g_test_run () call below.</span>
<span class="comment">   */</span>
<span class="normal">  </span><span class="function"><a href="glib-Testing.html#g-test-add-func">g_test_add_func</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"/myobject/create_large_object/subprocess"</span><span class="symbol">,</span>
<span class="normal">                   test_create_large_object_subprocess</span><span class="symbol">);</span>

<span class="normal">  </span><span class="keyword">return</span><span class="normal"> </span><span class="function"><a href="glib-Testing.html#g-test-run">g_test_run</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="cbracket">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_path</code></em> :</span></p></td>
<td>Test to run in a subprocess</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>usec_timeout</code></em> :</span></p></td>
<td>Timeout for the subprocess test in micro seconds.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_flags</code></em> :</span></p></td>
<td>Flags to modify subprocess behaviour.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.38</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-has-passed"></a><h3>g_test_trap_has_passed ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_test_trap_has_passed              (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Check the result of the last <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> call.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the last test subprocess terminated successfully.</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-reached-timeout"></a><h3>g_test_trap_reached_timeout ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_test_trap_reached_timeout         (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Check the result of the last <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> call.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the last test subprocess got killed due to a timeout.</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-passed"></a><h3>g_test_trap_assert_passed</h3>
<pre class="programlisting">#define             g_test_trap_assert_passed()</pre>
<p>
Assert that the last test subprocess passed.
See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.
</p>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-failed"></a><h3>g_test_trap_assert_failed</h3>
<pre class="programlisting">#define             g_test_trap_assert_failed()</pre>
<p>
Assert that the last test subprocess failed.
See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.
</p>
<p>
This is sometimes used to test situations that are formally considered to
be undefined behaviour, like inputs that fail a <a class="link" href="glib-Warnings-and-Assertions.html#g-return-if-fail" title="g_return_if_fail()"><code class="function">g_return_if_fail()</code></a>
check. In these situations you should skip the entire test, including the
call to <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>, unless <a class="link" href="glib-Testing.html#g-test-undefined" title="g_test_undefined"><code class="function">g_test_undefined()</code></a> returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>
to indicate that undefined behaviour may be tested.
</p>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-stdout"></a><h3>g_test_trap_assert_stdout()</h3>
<pre class="programlisting">#define             g_test_trap_assert_stdout(soutpattern)</pre>
<p>
Assert that the stdout output of the last test subprocess matches
<em class="parameter"><code>soutpattern</code></em>. See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>soutpattern</code></em> :</span></p></td>
<td>a glob-style
<a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-stdout-unmatched"></a><h3>g_test_trap_assert_stdout_unmatched()</h3>
<pre class="programlisting">#define             g_test_trap_assert_stdout_unmatched(soutpattern)</pre>
<p>
Assert that the stdout output of the last test subprocess
does not match <em class="parameter"><code>soutpattern</code></em>. See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>soutpattern</code></em> :</span></p></td>
<td>a glob-style
<a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-stderr"></a><h3>g_test_trap_assert_stderr()</h3>
<pre class="programlisting">#define             g_test_trap_assert_stderr(serrpattern)</pre>
<p>
Assert that the stderr output of the last test subprocess
matches <em class="parameter"><code>serrpattern</code></em>. See  <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.
</p>
<p>
This is sometimes used to test situations that are formally
considered to be undefined behaviour, like code that hits a
<a class="link" href="glib-Testing.html#g-assert" title="g_assert()"><code class="function">g_assert()</code></a> or <a class="link" href="glib-Message-Logging.html#g-error" title="g_error()"><code class="function">g_error()</code></a>. In these situations you should skip the
entire test, including the call to <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>, unless
<a class="link" href="glib-Testing.html#g-test-undefined" title="g_test_undefined"><code class="function">g_test_undefined()</code></a> returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> to indicate that undefined
behaviour may be tested.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>serrpattern</code></em> :</span></p></td>
<td>a glob-style
<a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-assert-stderr-unmatched"></a><h3>g_test_trap_assert_stderr_unmatched()</h3>
<pre class="programlisting">#define             g_test_trap_assert_stderr_unmatched(serrpattern)</pre>
<p>
Assert that the stderr output of the last test subprocess
does not match <em class="parameter"><code>serrpattern</code></em>. See <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>serrpattern</code></em> :</span></p></td>
<td>a glob-style
<a class="link" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching">pattern</a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-trap-fork"></a><h3>g_test_trap_fork ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_test_trap_fork                    (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint64" title="guint64"><span class="type">guint64</span></a> usec_timeout</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestTrapFlags" title="enum GTestTrapFlags"><span class="type">GTestTrapFlags</span></a> test_trap_flags</code></em>);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_test_trap_fork</code> is deprecated and should not be used in newly-written code. This function is implemented only on Unix platforms,
and is not always reliable due to problems inherent in
fork-without-exec. Use <a class="link" href="glib-Testing.html#g-test-trap-subprocess" title="g_test_trap_subprocess ()"><code class="function">g_test_trap_subprocess()</code></a> instead.</p>
</div>
<p>
Fork the current test program to execute a test case that might
not return or that might abort.
</p>
<p>
If <em class="parameter"><code>usec_timeout</code></em> is non-0, the forked test case is aborted and
considered failing if its run time exceeds it.
</p>
<p>
The forking behavior can be configured with the <a class="link" href="glib-Testing.html#GTestTrapFlags" title="enum GTestTrapFlags"><span class="type">GTestTrapFlags</span></a> flags.
</p>
<p>
In the following example, the test code forks, the forked child
process produces some sample output and exits successfully.
The forking parent process then asserts successful child program
termination and validates child program outputs.
</p>
<p>
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">test_fork_patterns</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">  </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-Testing.html#g-test-trap-fork">g_test_trap_fork</a></span><span class="normal"> </span><span class="symbol">(</span><span class="number">0</span><span class="symbol">,</span><span class="normal"> <a href="glib-Testing.html#G-TEST-TRAP-SILENCE-STDOUT:CAPS">G_TEST_TRAP_SILENCE_STDOUT</a> </span><span class="symbol">|</span><span class="normal"> <a href="glib-Testing.html#G-TEST-TRAP-SILENCE-STDERR:CAPS">G_TEST_TRAP_SILENCE_STDERR</a></span><span class="symbol">))</span>
<span class="normal">    </span><span class="cbracket">{</span>
<span class="normal">      </span><span class="function"><a href="glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"some stdout text: somagic17</span><span class="specialchar">\n</span><span class="string">"</span><span class="symbol">);</span>
<span class="normal">      </span><span class="function"><a href="glib-Warnings-and-Assertions.html#g-printerr">g_printerr</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"some stderr text: semagic43</span><span class="specialchar">\n</span><span class="string">"</span><span class="symbol">);</span>
<span class="normal">      </span><span class="function">exit</span><span class="normal"> </span><span class="symbol">(</span><span class="number">0</span><span class="symbol">);</span><span class="normal"> </span><span class="comment">/* successful test run */</span>
<span class="normal">    </span><span class="cbracket">}</span>
<span class="normal">  </span><span class="function"><a href="glib-Testing.html#g-test-trap-assert-passed">g_test_trap_assert_passed</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal">  </span><span class="function"><a href="glib-Testing.html#g-test-trap-assert-stdout">g_test_trap_assert_stdout</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"*somagic17*"</span><span class="symbol">);</span>
<span class="normal">  </span><span class="function"><a href="glib-Testing.html#g-test-trap-assert-stderr">g_test_trap_assert_stderr</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"*semagic43*"</span><span class="symbol">);</span>
<span class="cbracket">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>usec_timeout</code></em> :</span></p></td>
<td>Timeout for the forked test in micro seconds.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_trap_flags</code></em> :</span></p></td>
<td>Flags to modify forking behaviour.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> for the forked child and <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> for the executing parent process.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-rand-bit"></a><h3>g_test_rand_bit</h3>
<pre class="programlisting">#define             g_test_rand_bit()</pre>
<p>
Get a reproducible random bit (0 or 1), see <a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()"><code class="function">g_test_rand_int()</code></a>
for details on test case random numbers.
</p>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-rand-int"></a><h3>g_test_rand_int ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a>              g_test_rand_int                     (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Get a reproducible random integer number.
</p>
<p>
The random numbers generated by the g_test_rand_*() family of functions
change with every new test program start, unless the --seed option is
given when starting test programs.
</p>
<p>
For individual test cases however, the random number generator is
reseeded, to avoid dependencies between tests and to make --seed
effective for all test cases.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a random number from the seeded random number generator.</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-rand-int-range"></a><h3>g_test_rand_int_range ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a>              g_test_rand_int_range               (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="type">gint32</span></a> begin</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="type">gint32</span></a> end</code></em>);</pre>
<p>
Get a reproducible random integer number out of a specified range,
see <a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()"><code class="function">g_test_rand_int()</code></a> for details on test case random numbers.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>begin</code></em> :</span></p></td>
<td>the minimum value returned by this function</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>end</code></em> :</span></p></td>
<td>the smallest value not to be returned by this function</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a number with <em class="parameter"><code>begin</code></em> &lt;= number &lt; <em class="parameter"><code>end</code></em>.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-rand-double"></a><h3>g_test_rand_double ()</h3>
<pre class="programlisting"><span class="returnvalue">double</span>              g_test_rand_double                  (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Get a reproducible random floating point number,
see <a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()"><code class="function">g_test_rand_int()</code></a> for details on test case random numbers.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a random number from the seeded random number generator.</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-rand-double-range"></a><h3>g_test_rand_double_range ()</h3>
<pre class="programlisting"><span class="returnvalue">double</span>              g_test_rand_double_range            (<em class="parameter"><code><span class="type">double</span> range_start</code></em>,
                                                         <em class="parameter"><code><span class="type">double</span> range_end</code></em>);</pre>
<p>
Get a reproducible random floating pointer number out of a specified range,
see <a class="link" href="glib-Testing.html#g-test-rand-int" title="g_test_rand_int ()"><code class="function">g_test_rand_int()</code></a> for details on test case random numbers.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>range_start</code></em> :</span></p></td>
<td>the minimum value returned by this function</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>range_end</code></em> :</span></p></td>
<td>the minimum value not returned by this function</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a number with <em class="parameter"><code>range_start</code></em> &lt;= number &lt; <em class="parameter"><code>range_end</code></em>.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert"></a><h3>g_assert()</h3>
<pre class="programlisting">#define             g_assert(expr)</pre>
<p>
Debugging macro to terminate the application if the assertion
fails. If the assertion fails (i.e. the expression is not true),
an error message is logged and the application is terminated.
</p>
<p>
The macro can be turned off in final releases of code by defining
<code class="envar">G_DISABLE_ASSERT</code> when compiling the application.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>expr</code></em> :</span></p></td>
<td>the expression to check</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-not-reached"></a><h3>g_assert_not_reached</h3>
<pre class="programlisting">#define             g_assert_not_reached()</pre>
<p>
Debugging macro to terminate the application if it is ever
reached. If it is reached, an error message is logged and the
application is terminated.
</p>
<p>
The macro can be turned off in final releases of code by defining
<code class="envar">G_DISABLE_ASSERT</code> when compiling the application.
</p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmpstr"></a><h3>g_assert_cmpstr()</h3>
<pre class="programlisting">#define             g_assert_cmpstr(s1, cmp, s2)</pre>
<p>
Debugging macro to compare two strings. If the comparison fails,
an error message is logged and the application is either terminated
or the testcase marked as failed.
The strings are compared using <a class="link" href="glib-String-Utility-Functions.html#g-strcmp0" title="g_strcmp0 ()"><code class="function">g_strcmp0()</code></a>.
</p>
<p>
The effect of <code class="literal">g_assert_cmpstr (s1, op, s2)</code> is
the same as <code class="literal">g_assert_true (g_strcmp0 (s1, s2) op 0)</code>.
The advantage of this macro is that it can produce a message that
includes the actual values of <em class="parameter"><code>s1</code></em> and <em class="parameter"><code>s2</code></em>.
</p>
<p>
</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function"><a href="glib-Testing.html#g-assert-cmpstr">g_assert_cmpstr</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">mystring</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">==,</span><span class="normal"> </span><span class="string">"fubar"</span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>s1</code></em> :</span></p></td>
<td>a string (may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>)</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
<td>The comparison operator to use.
One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>s2</code></em> :</span></p></td>
<td>another string (may be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>)</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmpint"></a><h3>g_assert_cmpint()</h3>
<pre class="programlisting">#define             g_assert_cmpint(n1, cmp, n2)</pre>
<p>
Debugging macro to compare two integers.
</p>
<p>
The effect of <code class="literal">g_assert_cmpint (n1, op, n2)</code> is
the same as <code class="literal">g_assert_true (n1 op n2)</code>. The advantage
of this macro is that it can produce a message that includes the
actual values of <em class="parameter"><code>n1</code></em> and <em class="parameter"><code>n2</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>n1</code></em> :</span></p></td>
<td>an integer</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
<td>The comparison operator to use.
One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n2</code></em> :</span></p></td>
<td>another integer</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmpuint"></a><h3>g_assert_cmpuint()</h3>
<pre class="programlisting">#define             g_assert_cmpuint(n1, cmp, n2)</pre>
<p>
Debugging macro to compare two unsigned integers.
</p>
<p>
The effect of <code class="literal">g_assert_cmpuint (n1, op, n2)</code> is
the same as <code class="literal">g_assert_true (n1 op n2)</code>. The advantage
of this macro is that it can produce a message that includes the
actual values of <em class="parameter"><code>n1</code></em> and <em class="parameter"><code>n2</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>n1</code></em> :</span></p></td>
<td>an unsigned integer</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
<td>The comparison operator to use.
One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n2</code></em> :</span></p></td>
<td>another unsigned integer</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmphex"></a><h3>g_assert_cmphex()</h3>
<pre class="programlisting">#define             g_assert_cmphex(n1, cmp, n2)</pre>
<p>
Debugging macro to compare to unsigned integers.
</p>
<p>
This is a variant of <a class="link" href="glib-Testing.html#g-assert-cmpuint" title="g_assert_cmpuint()"><code class="function">g_assert_cmpuint()</code></a> that displays the numbers
in hexadecimal notation in the message.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>n1</code></em> :</span></p></td>
<td>an unsigned integer</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
<td>The comparison operator to use.
One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n2</code></em> :</span></p></td>
<td>another unsigned integer</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-cmpfloat"></a><h3>g_assert_cmpfloat()</h3>
<pre class="programlisting">#define             g_assert_cmpfloat(n1,cmp,n2)</pre>
<p>
Debugging macro to compare two floating point numbers.
</p>
<p>
The effect of <code class="literal">g_assert_cmpfloat (n1, op, n2)</code> is
the same as <code class="literal">g_assert_true (n1 op n2)</code>. The advantage
of this macro is that it can produce a message that includes the
actual values of <em class="parameter"><code>n1</code></em> and <em class="parameter"><code>n2</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>n1</code></em> :</span></p></td>
<td>an floating point number</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cmp</code></em> :</span></p></td>
<td>The comparison operator to use.
One of ==, !=, &lt;, &gt;, &lt;=, &gt;=.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n2</code></em> :</span></p></td>
<td>another floating point number</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-no-error"></a><h3>g_assert_no_error()</h3>
<pre class="programlisting">#define             g_assert_no_error(err)</pre>
<p>
Debugging macro to check that a <a class="link" href="glib-Error-Reporting.html#GError" title="struct GError"><span class="type">GError</span></a> is not set.
</p>
<p>
The effect of <code class="literal">g_assert_no_error (err)</code> is
the same as <code class="literal">g_assert_true (err == NULL)</code>. The advantage
of this macro is that it can produce a message that includes
the error message and code.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Error-Reporting.html#GError" title="struct GError"><span class="type">GError</span></a>, possibly <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.20</p>
</div>
<hr>
<div class="refsect2">
<a name="g-assert-error"></a><h3>g_assert_error()</h3>
<pre class="programlisting">#define             g_assert_error(err, dom, c)</pre>
<p>
Debugging macro to check that a method has returned
the correct <a class="link" href="glib-Error-Reporting.html#GError" title="struct GError"><span class="type">GError</span></a>.
</p>
<p>
The effect of <code class="literal">g_assert_error (err, dom, c)</code> is
the same as <code class="literal">g_assert_true (err != NULL &amp;&amp; err-&gt;domain
== dom &amp;&amp; err-&gt;code == c)</code>. The advantage of this
macro is that it can produce a message that includes the incorrect
error message and code.
</p>
<p>
This can only be used to test for a specific error. If you want to
test that <em class="parameter"><code>err</code></em> is set, but don't care what it's set to, just use
<code class="literal">g_assert (err != NULL)</code>
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>err</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Error-Reporting.html#GError" title="struct GError"><span class="type">GError</span></a>, possibly <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>dom</code></em> :</span></p></td>
<td>the expected error domain (a <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>)</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>c</code></em> :</span></p></td>
<td>the expected error code</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.20</p>
</div>
<hr>
<div class="refsect2">
<a name="GTestCase"></a><h3>GTestCase</h3>
<pre class="programlisting">typedef struct GTestCase  GTestCase;
</pre>
<p>
An opaque structure representing a test case.
</p>
</div>
<hr>
<div class="refsect2">
<a name="GTestSuite"></a><h3>GTestSuite</h3>
<pre class="programlisting">typedef struct GTestSuite GTestSuite;
</pre>
<p>
An opaque structure representing a test suite.
</p>
</div>
<hr>
<div class="refsect2">
<a name="GTestFixtureFunc"></a><h3>GTestFixtureFunc ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                (*GTestFixtureFunc)                 (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> fixture</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> user_data</code></em>);</pre>
<p>
The type used for functions that operate on test fixtures.  This is
used for the fixture setup and teardown functions as well as for the
testcases themselves.
</p>
<p>
<em class="parameter"><code>user_data</code></em> is a pointer to the data that was given when registering
the test case.
</p>
<p>
<em class="parameter"><code>fixture</code></em> will be a pointer to the area of memory allocated by the
test framework, of the size requested.  If the requested size was
zero then <em class="parameter"><code>fixture</code></em> will be equal to <em class="parameter"><code>user_data</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>fixture</code></em> :</span></p></td>
<td>the test fixture</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>the data provided when registering the test</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.28</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-create-case"></a><h3>g_test_create_case ()</h3>
<pre class="programlisting"><a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="returnvalue">GTestCase</span></a> *         g_test_create_case                  (<em class="parameter"><code>const <span class="type">char</span> *test_name</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> data_size</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> test_data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()"><span class="type">GTestFixtureFunc</span></a> data_setup</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()"><span class="type">GTestFixtureFunc</span></a> data_test</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestFixtureFunc" title="GTestFixtureFunc ()"><span class="type">GTestFixtureFunc</span></a> data_teardown</code></em>);</pre>
<p>
Create a new <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a>, named <em class="parameter"><code>test_name</code></em>, this API is fairly
low level, calling <a class="link" href="glib-Testing.html#g-test-add" title="g_test_add()"><code class="function">g_test_add()</code></a> or <a class="link" href="glib-Testing.html#g-test-add-func" title="g_test_add_func ()"><code class="function">g_test_add_func()</code></a> is preferable.
When this test is executed, a fixture structure of size <em class="parameter"><code>data_size</code></em>
will be allocated and filled with 0s. Then <em class="parameter"><code>data_setup</code></em> is called
to initialize the fixture. After fixture setup, the actual test
function <em class="parameter"><code>data_test</code></em> is called. Once the test run completed, the
fixture structure is torn down  by calling <em class="parameter"><code>data_teardown</code></em> and
after that the memory is released.
</p>
<p>
Splitting up a test run into fixture setup, test function and
fixture teardown is most usful if the same fixture is used for
multiple tests. In this cases, <a class="link" href="glib-Testing.html#g-test-create-case" title="g_test_create_case ()"><code class="function">g_test_create_case()</code></a> will be
called with the same fixture, but varying <em class="parameter"><code>test_name</code></em> and
<em class="parameter"><code>data_test</code></em> arguments.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_name</code></em> :</span></p></td>
<td>the name for the test case</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data_size</code></em> :</span></p></td>
<td>the size of the fixture data structure</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_data</code></em> :</span></p></td>
<td>test data argument for the test functions</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data_setup</code></em> :</span></p></td>
<td>the function to set up the fixture data</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data_test</code></em> :</span></p></td>
<td>the actual test function</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data_teardown</code></em> :</span></p></td>
<td>the function to teardown the fixture data</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a newly allocated <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a>.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-create-suite"></a><h3>g_test_create_suite ()</h3>
<pre class="programlisting"><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="returnvalue">GTestSuite</span></a> *        g_test_create_suite                 (<em class="parameter"><code>const <span class="type">char</span> *suite_name</code></em>);</pre>
<p>
Create a new test suite with the name <em class="parameter"><code>suite_name</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>suite_name</code></em> :</span></p></td>
<td>a name for the suite</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly allocated <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> instance.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-get-root"></a><h3>g_test_get_root ()</h3>
<pre class="programlisting"><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="returnvalue">GTestSuite</span></a> *        g_test_get_root                     (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Get the toplevel test suite for the test path API.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the toplevel <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-suite-add"></a><h3>g_test_suite_add ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_suite_add                    (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *suite</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a> *test_case</code></em>);</pre>
<p>
Adds <em class="parameter"><code>test_case</code></em> to <em class="parameter"><code>suite</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>suite</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>test_case</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Testing.html#GTestCase" title="GTestCase"><span class="type">GTestCase</span></a>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-suite-add-suite"></a><h3>g_test_suite_add_suite ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_test_suite_add_suite              (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *suite</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *nestedsuite</code></em>);</pre>
<p>
Adds <em class="parameter"><code>nestedsuite</code></em> to <em class="parameter"><code>suite</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>suite</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>nestedsuite</code></em> :</span></p></td>
<td>another <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
<hr>
<div class="refsect2">
<a name="g-test-run-suite"></a><h3>g_test_run_suite ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span>                 g_test_run_suite                    (<em class="parameter"><code><a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a> *suite</code></em>);</pre>
<p>
Execute the tests within <em class="parameter"><code>suite</code></em> and all nested <a href="glib-Testing.html#GTestSuite"><span class="type">GTestSuites</span></a>.
The test suites to be executed are filtered according to
test path arguments (-p <em class="replaceable"><code>testpath</code></em>) 
as parsed by <a class="link" href="glib-Testing.html#g-test-init" title="g_test_init ()"><code class="function">g_test_init()</code></a>.
<a class="link" href="glib-Testing.html#g-test-run-suite" title="g_test_run_suite ()"><code class="function">g_test_run_suite()</code></a> or <a class="link" href="glib-Testing.html#g-test-run" title="g_test_run ()"><code class="function">g_test_run()</code></a> may only be called once
in a program.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>suite</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Testing.html#GTestSuite" title="GTestSuite"><span class="type">GTestSuite</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.16</p>
</div>
</div>
<div class="refsect1">
<a name="glib-Testing.see-also"></a><h2>See Also</h2>
<a href="gtester.html">gtester</a>,
           <a href="gtester-report.html">gtester-report</a>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.19</div>
</body>
</html>