2c669290df8e7de8b4661c7261191a3028b51dd4
[pspp] / tests / ui / syntax-gen-test.c
1 #include <config.h>
2
3 #include "ui/syntax-gen.h"
4
5 #include <stdio.h>
6
7 static void
8 test_runner (const char *format, ...)
9 {
10   struct string syntax;
11   va_list args;
12   va_start (args, format);
13
14   ds_init_empty (&syntax);
15   
16   syntax_gen_pspp_valist (&syntax, format, args);
17
18   va_end (args);
19
20   puts (ds_cstr (&syntax));
21
22   ds_destroy (&syntax);  
23 }
24
25 int
26 main (void)
27 {
28   test_runner ("A simple string: %ssEND", "Hello world");
29   test_runner ("A syntax string: %sqEND", "Hello world");
30   test_runner ("A syntax string containing \": %sqEND", "here\"is the quote");
31   test_runner ("A syntax string containing non-printables: %sqEND", "A CtrlL\fchar");
32   test_runner ("An integer: %dEND", 98765);
33   test_runner ("A floating point number: %gEND", 3.142);
34   test_runner ("A floating point number with default precision: %fEND", 1.234);
35   test_runner ("A literal %%");
36
37   test_runner ("and %ss a %sq of %d different %f examples %g of 100%% conversions.",
38                "finally", "concatination", 6, 20.309, 23.09);
39
40   return 0;
41 }