/*
   <p>Test harness for the trim function.</p>

   <kbd>
   <b>environ - C programming support functions</b><br>
   Copyright (C) 2005  Martin C Gregorie
   
   This program is free software; you can redistribute it and/or
   modify it under the terms of the Lesser GNU General Public License.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
  
   You should have received a copy of the Lesser GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
   </kbd>
  
   <p>Contact Martin Gregorie at <i>martin@gregorie.org</i></p>
*/

#include <stdio.h>
#include <stdlib.h>
#include "environ.h"

#ifdef OS9
#include <strings.h>
#else
#include <string.h>
#endif

void test(char *s, char *e)
{
   char r[MAXLINE];
   char bs[MAXLINE];
   char br[MAXLINE];
   char be[MAXLINE];

   trim(r, s);
   if (strcmp(r, e) != 0)
   {
      strncpy(bs, strhex(s), MAXLINE);
      strncpy(br, strhex(r), MAXLINE);
      printf("'%s' should give '%s': got '%s'\n", bs, e, br);
   }
}

main(int argc, char **argv)
{
    printf("No output expected from correct operation\n");
    test("", "");
    test(" ", "");
    test("  ", "");
    test("x", "x");
    test("xs ", "xs");    
    test(" sx", "sx");
    test(" sxs ", "sxs");
    test("\ttxt\t", "txt");
    test("\nnxn\n", "nxn");
    test("\rrxr\r", "rxr");
    test("\ffxf\f", "fxf");
    test("   A short sentence.   ", "A short sentence.");
    printf("Test ended\n");
    return(0);
}
