]> code.delx.au - gnu-emacs-elpa/commitdiff
tests: Add line wrapping tests
authorDaiki Ueno <ueno@gnu.org>
Tue, 19 Jan 2016 06:13:56 +0000 (15:13 +0900)
committerDaiki Ueno <ueno@gnu.org>
Tue, 19 Jan 2016 06:13:56 +0000 (15:13 +0900)
gnome-c-tests.el

index 59ae8ee7a7d46fa591cd634eded7941437c595a9..3b484633c0aafc9a2392a67bbd833be181d119c1 100644 (file)
@@ -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