]> code.delx.au - gnu-emacs-elpa/blob - gobject-tests.el
c06c0a5efaff0bb3243048d65f528c4db0840782
[gnu-emacs-elpa] / gobject-tests.el
1 (require 'gobject-align)
2
3 (defconst gobject-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 gobject-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 gobject-test-program-2 "\
44 GDK_AVAILABLE_IN_3_16
45 const gchar ** gtk_widget_list_action_prefixes (GtkWidget *widget);
46 ")
47
48 (ert-deftest gobject-test-align--compute-optimal-columns ()
49 "Tests the `gobject-align--compute-optimal-columns'."
50 (with-temp-buffer
51 (insert gobject-test-program-1)
52 (c-mode)
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)))))
57
58 (ert-deftest gobject-test-align-region ()
59 "Tests the `gobject-align-region'."
60 (with-temp-buffer
61 (insert gobject-test-program-1)
62 (c-mode)
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))))
66
67 (ert-deftest gobject-test-align-guess-columns ()
68 "Tests the `gobject-align-guess-columns'."
69 (with-temp-buffer
70 (insert gobject-test-program-2)
71 (c-mode)
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))))