]> code.delx.au - gnu-emacs-elpa/blob - gnome-tests.el
align: Add a room before '*' for arguments
[gnu-emacs-elpa] / gnome-tests.el
1 (require 'gnome-align)
2
3 (defconst gnome-test-program-1 "\
4 GGpgCtx *g_gpg_ctx_new (GError **error);
5
6 typedef void (*GGpgProgressCallback) (gpointer user_data,
7 const gchar *what,
8 gint type,
9 gint current,
10 gint total);
11
12 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
13 GGpgProgressCallback callback,
14 gpointer user_data,
15 GDestroyNotify destroy_data);
16 void g_gpg_ctx_add_signer (GGpgCtx *ctx, GGpgKey *key);
17 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
18 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx, guint index);
19 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
20 ")
21
22 (defconst gnome-test-program-1-aligned "\
23 GGpgCtx *g_gpg_ctx_new (GError **error);
24
25 typedef void (*GGpgProgressCallback) (gpointer user_data,
26 const gchar *what,
27 gint type,
28 gint current,
29 gint total);
30
31 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
32 GGpgProgressCallback callback,
33 gpointer user_data,
34 GDestroyNotify destroy_data);
35 void g_gpg_ctx_add_signer (GGpgCtx *ctx,
36 GGpgKey *key);
37 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
38 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx,
39 guint index);
40 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
41 ")
42
43 (defconst gnome-test-program-2 "\
44 GDK_AVAILABLE_IN_3_16
45 const gchar ** gtk_widget_list_action_prefixes (GtkWidget *widget);
46 ")
47
48 (defconst gnome-test-program-3 "\
49 /* overridable methods */
50 void (*set_property) (GObject *object,
51 guint property_id,
52 const GValue *value,
53 GParamSpec *pspec);
54 void (*get_property) (GObject *object,
55 guint property_id,
56 GValue *value,
57 GParamSpec *pspec);
58 ")
59
60 (ert-deftest gnome-test-align--compute-optimal-columns ()
61 "Tests the `gnome-align--compute-optimal-columns'."
62 (with-temp-buffer
63 (insert gnome-test-program-1)
64 (c-mode)
65 (let ((columns (gnome-align--compute-optimal-columns (point-min) (point-max))))
66 (should (= (cdr (assq 'identifier-start-column columns)) 9))
67 (should (= (cdr (assq 'arglist-start-column columns)) 41))
68 (should (= (cdr (assq 'arglist-identifier-start-column columns)) 64)))))
69
70 (ert-deftest gnome-test-align-region ()
71 "Tests the `gnome-align-region'."
72 (with-temp-buffer
73 (insert gnome-test-program-1)
74 (c-mode)
75 (gnome-align-compute-optimal-columns (point-min) (point-max))
76 (gnome-align-region (point-min) (point-max))
77 (should (equal (buffer-string) gnome-test-program-1-aligned))))
78
79 (ert-deftest gnome-test-align-guess-columns-1 ()
80 "Tests the `gnome-align-guess-columns'."
81 (with-temp-buffer
82 (insert gnome-test-program-2)
83 (c-mode)
84 (gnome-align-guess-columns (point-min) (point-max))
85 (should (= gnome-align-identifier-start-column 24))
86 (should (= gnome-align-arglist-start-column 56))
87 (should (= gnome-align-arglist-identifier-start-column 80))))
88
89 (ert-deftest gnome-test-align-guess-columns-2 ()
90 "Tests the `gnome-align-guess-columns'."
91 (with-temp-buffer
92 (insert gnome-test-program-3)
93 (c-mode)
94 (gnome-align-guess-columns (point-min) (point-max))
95 (should (= gnome-align-identifier-start-column 13))
96 (should (= gnome-align-arglist-start-column 40))
97 (should (= gnome-align-arglist-identifier-start-column 57))))