From 03f8dca09e2498b8325b3583d481ef33c84bf2f0 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Tue, 19 Jan 2016 15:13:56 +0900 Subject: [PATCH] tests: Add line wrapping tests --- gnome-c-tests.el | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/gnome-c-tests.el b/gnome-c-tests.el index 59ae8ee7a..3b484633c 100644 --- a/gnome-c-tests.el +++ b/gnome-c-tests.el @@ -78,6 +78,34 @@ int *bar (const char * const **a, int b); ") +(defconst gnome-c-test-program-6 "\ +int foo (char **a, int b); +type_1234567890 bar (char a, int b); +int identifier_1234567890 (double a, double b); +") + +(defconst gnome-c-test-program-6-aligned-1 "\ +int foo + (char **a, + int b); +type_1234567890 bar + (char a, + int b); +int identifier_1234567890 + (double a, + double b); +") + +(defconst gnome-c-test-program-6-aligned-2 "\ +int foo (char **a, + int b); +type_1234567890 bar (char a, + int b); +int identifier_1234567890 + (double a, + double b); +") + (ert-deftest gnome-c-test-align--guess-optimal-columns () "Tests the `gnome-c-align--guess-optimal-columns'." (with-temp-buffer @@ -120,6 +148,26 @@ int *bar (const char * const **a, (gnome-c-align-decls-region (point-min) (point-max))) (should (equal (buffer-string) gnome-c-test-program-5-aligned)))) +(ert-deftest gnome-c-test-align-region-4 () + "Tests the `gnome-c-align-decls-region', with max columns set." + (with-temp-buffer + (insert gnome-c-test-program-6) + (c-mode) + (let ((gnome-c-align-max-column 20)) + (gnome-c-align-guess-optimal-columns (point-min) (point-max)) + (gnome-c-align-decls-region (point-min) (point-max))) + (should (equal (buffer-string) gnome-c-test-program-6-aligned-1)))) + +(ert-deftest gnome-c-test-align-region-5 () + "Tests the `gnome-c-align-decls-region', with max columns set." + (with-temp-buffer + (insert gnome-c-test-program-6) + (c-mode) + (let ((gnome-c-align-max-column 30)) + (gnome-c-align-guess-optimal-columns (point-min) (point-max)) + (gnome-c-align-decls-region (point-min) (point-max))) + (should (equal (buffer-string) gnome-c-test-program-6-aligned-2)))) + (ert-deftest gnome-c-test-align-guess-columns-1 () "Tests the `gnome-c-align-guess-columns'." (with-temp-buffer -- 2.39.2