[1818] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[PATCH 2/3] Add fill-paragraph test case for owl_editwin

daemon@ATHENA.MIT.EDU (David Benjamin)
Thu Oct 29 18:22:41 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
X-Original-To: nelhage@lunatique.mit.edu
From: David Benjamin <davidben@MIT.EDU>
To: barnowl-dev@mit.edu
Date: Mon, 19 Oct 2009 20:30:25 -0400
In-Reply-To: <1255998626-11366-2-git-send-email-davidben@mit.edu>

One of them currently fails.

Signed-off-by: David Benjamin <davidben@mit.edu>
---
 tester.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/tester.c b/tester.c
index 35a4c2d..52d3c73 100644
--- a/tester.c
+++ b/tester.c
@@ -11,6 +11,7 @@ int owl_dict_regtest(void);
 int owl_variable_regtest(void);
 int owl_filter_regtest(void);
 int owl_obarray_regtest(void);
+int owl_editwin_regtest(void);
 
 int main(int argc, char **argv, char **env)
 {
@@ -28,6 +29,7 @@ int main(int argc, char **argv, char **env)
   numfailures += owl_variable_regtest();
   numfailures += owl_filter_regtest();
   numfailures += owl_obarray_regtest();
+  numfailures += owl_editwin_regtest();
   if (numfailures) {
       fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
   }
@@ -305,3 +307,43 @@ int owl_obarray_regtest(void) {
 
   return numfailed;
 }
+
+int owl_editwin_regtest(void) {
+  int numfailed = 0;
+  const char *p;
+
+  printf("# BEGIN testing owl_editwin\n");
+
+  owl_editwin *oe;
+  oe = owl_editwin_allocate();
+  owl_editwin_init(oe, NULL, 80, 80, OWL_EDITWIN_STYLE_MULTILINE, NULL);
+
+  /* TODO: make the strings a little more lenient w.r.t trailing whitespace */
+
+  /* check paragraph fill */
+  owl_editwin_insert_string(oe, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.\n\nblah");
+  owl_editwin_move_to_top(oe);
+  owl_editwin_fill_paragraph(oe);
+  p = owl_editwin_get_text(oe);
+  FAIL_UNLESS("text was correctly wrapped", p && !strcmp(p, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n"
+							    "blah blah blah.\n"
+							    "\n"
+							    "blah"));
+
+  /* check that lines ending with ". " correctly fill */
+  owl_editwin_fullclear(oe);
+  owl_editwin_insert_string(oe, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah. \n\nblah");
+  owl_editwin_move_to_top(oe);
+  owl_editwin_fill_paragraph(oe);
+  p = owl_editwin_get_text(oe);
+  FAIL_UNLESS("text was correctly wrapped", p && !strcmp(p, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n"
+							    "blah blah blah. \n"
+							    "\n"
+							    "blah"));
+
+  owl_editwin_free(oe);
+
+  printf("# END testing owl_editwin (%d failures)\n", numfailed);
+
+  return numfailed;
+}
-- 
1.6.3.3


home help back first fref pref prev next nref lref last post