1 (require 'gobject-align)
3 (defconst gobject-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 gobject-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 gobject-test-program-2 "\
45 const gchar ** gtk_widget_list_action_prefixes (GtkWidget *widget);
48 (ert-deftest gobject-test-align--compute-optimal-columns ()
49 "Tests the `gobject-align--compute-optimal-columns'."
51 (insert gobject-test-program-1)
53 (let ((columns (gobject-align--compute-optimal-columns (point-min) (point-max))))
54 (should (= (cdr (assq 'identifier-start-column columns)) 9))
55 (should (= (cdr (assq 'arglist-start-column columns)) 41))
56 (should (= (cdr (assq 'arglist-identifier-start-column columns)) 63)))))
58 (ert-deftest gobject-test-align-region ()
59 "Tests the `gobject-align-region'."
61 (insert gobject-test-program-1)
63 (gobject-align-compute-optimal-columns (point-min) (point-max))
64 (gobject-align-region (point-min) (point-max))
65 (should (equal (buffer-string) gobject-test-program-1-aligned))))
67 (ert-deftest gobject-test-align-guess-columns ()
68 "Tests the `gobject-align-guess-columns'."
70 (insert gobject-test-program-2)
72 (gobject-align-guess-columns (point-min) (point-max))
73 (should (= gobject-align-identifier-start-column 24))
74 (should (= gobject-align-arglist-start-column 56))
75 (should (= gobject-align-arglist-identifier-start-column 80))))