]> code.delx.au - gnu-emacs-elpa/blob - gobject-tests.el
Add ERT tests
[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 (ert-deftest gobject-test-align--guess-columns ()
44 "Tests the `gobject-align--guess-columns'."
45 (with-temp-buffer
46 (insert gobject-test-program-1)
47 (c-mode)
48 (let ((columns (gobject-align--guess-columns (point-min) (point-max))))
49 (should (= (cdr (assq 'identifier-start-column columns)) 9))
50 (should (= (cdr (assq 'arglist-start-column columns)) 41))
51 (should (= (cdr (assq 'arglist-identifier-start-column columns)) 63)))))
52
53 (ert-deftest gobject-test-align-region ()
54 "Tests the `gobject-align-region'."
55 (with-temp-buffer
56 (insert gobject-test-program-1)
57 (c-mode)
58 (gobject-align-guess-columns (point-min) (point-max))
59 (gobject-align-region (point-min) (point-max))
60 (should (equal (buffer-string) gobject-test-program-1-aligned))))