3 (defconst gnome-test-program-1 "\
4 GGpgCtx *g_gpg_ctx_new (GError **error);
6 typedef void (*GGpgProgressCallback) (gpointer user_data,
12 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
13 GGpgProgressCallback callback,
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);
22 (defconst gnome-test-program-1-aligned "\
23 GGpgCtx *g_gpg_ctx_new (GError **error);
25 typedef void (*GGpgProgressCallback) (gpointer user_data,
31 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
32 GGpgProgressCallback callback,
34 GDestroyNotify destroy_data);
35 void g_gpg_ctx_add_signer (GGpgCtx *ctx,
37 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
38 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx,
40 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
43 (defconst gnome-test-program-2 "\
45 const gchar ** gtk_widget_list_action_prefixes (GtkWidget *widget);
48 (defconst gnome-test-program-3 "\
49 /* overridable methods */
50 void (*set_property) (GObject *object,
54 void (*get_property) (GObject *object,
60 (defconst gnome-test-program-4 "\
62 int foo (struct foo ***a, int b, ...) G_GNUC_CONST;
65 (defconst gnome-test-program-4-aligned "\
67 int foo (struct foo ***a,
72 (ert-deftest gnome-test-align--compute-optimal-columns ()
73 "Tests the `gnome-align--compute-optimal-columns'."
75 (insert gnome-test-program-1)
77 (let ((columns (gnome-align--compute-optimal-columns (point-min) (point-max))))
78 (should (= (cdr (assq 'identifier-start-column columns)) 9))
79 (should (= (cdr (assq 'arglist-start-column columns)) 41))
80 (should (= (cdr (assq 'arglist-identifier-start-column columns)) 64)))))
82 (ert-deftest gnome-test-align-region ()
83 "Tests the `gnome-align-region'."
85 (insert gnome-test-program-1)
87 (gnome-align-compute-optimal-columns (point-min) (point-max))
88 (gnome-align-region (point-min) (point-max))
89 (should (equal (buffer-string) gnome-test-program-1-aligned))))
91 (ert-deftest gnome-test-align-region-2 ()
92 "Tests the `gnome-align-region'."
94 (insert gnome-test-program-4)
96 (gnome-align-compute-optimal-columns (point-min) (point-max))
97 (gnome-align-region (point-min) (point-max))
98 (should (equal (buffer-string) gnome-test-program-4-aligned))))
100 (ert-deftest gnome-test-align-guess-columns-1 ()
101 "Tests the `gnome-align-guess-columns'."
103 (insert gnome-test-program-2)
105 (gnome-align-guess-columns (point-min) (point-max))
106 (should (= gnome-align-identifier-start-column 24))
107 (should (= gnome-align-arglist-start-column 56))
108 (should (= gnome-align-arglist-identifier-start-column 80))))
110 (ert-deftest gnome-test-align-guess-columns-2 ()
111 "Tests the `gnome-align-guess-columns'."
113 (insert gnome-test-program-3)
115 (gnome-align-guess-columns (point-min) (point-max))
116 (should (= gnome-align-identifier-start-column 13))
117 (should (= gnome-align-arglist-start-column 40))
118 (should (= gnome-align-arglist-identifier-start-column 57))))