
#include "V.h"
#include "str.h"
/*
* This is a simple test program for the str package.  If all is ok, it
* will produce no output at all, and will exit with status 0. If there
* are problems with  the  tested  routines,  error  messages  will  be
* produced, and the exit status will be the error count.
*
* If  there  are  problems,  you should probably run this program at a
* higher debug level:
*   setenv D_strtest 6Vtest.out
*   ./strtest.
*   edit strtest.out
*/
Str foo = {"foo",3};
Str bar = {"bar",3};
Str barn = {"barn",4};
Blk blk1 = {0};
Str str1 = {"Hello",5};

main(ac,av)
	int   ac;
	char**av;
{	int c;
	int e=0;	/* Error count */
	Str *sp0, *sp1;
	Blk *bp0, *bp1;

	ac = Vinit(ac,av);

	if (!(sp0 = MinStrM(0,15,"sp0"))) {
		V1 "MinStrM(0,15,...) failed to get 15 bytes for sp0." D;
		++e;
	}
	if (!(sp1 = MinStrM(&str1,15,"sp1"))) {
		V1 "MinStrM(&str1,15,...) failed to get 15 bytes for sp1." D;
		++e;
	}
	if (!(bp0 = MinBlkM(0,15,"bp0"))) {
		V1 "MinBlkM(0,15,...) failed to get 15 bytes for bp0." D;
		++e;
	}
	if (!(bp1 = MinBlkM(&blk1,15,"bp0"))) {
		V1 "MinBlkM(&blk1,15,...) failed to get 15 bytes for bp1." D;
		++e;
	}
	if ((c = CmpStrM(&bar,&foo,"bar-foo")) >= 0) {
		V1 "CmpStrM(%s,%s,...) gave %d.",DspSV(bar),DspSV(foo),c D;
		++e;
	}
	if ((c = CmpStrM(&foo,&bar,"foo-bar")) <= 0) {
		V1 "CmpStrM(%s,%s,...) gave %d.",DspSV(foo),DspSV(bar),c D;
		++e;
	}
	if ((c = CmpStrM(&bar,&barn,"bar-barn")) >= 0) {
		V1 "CmpStrM(%s,%s,...) gave %d.",DspSV(bar),DspSV(barn),c D;
		++e;
	}
	if ((c = CmpStrM(&barn,&bar,"barn-bar")) <= 0) {
		V1 "CmpStrM(%s,%s,...) gave %d.",DspSV(barn),DspSV(bar),c D;
		++e;
	}
	if ((c = CmpStrM(&foo,&foo,"foo-foo")) != 0) {
		V1 "CmpStrM(%s,%s,...) gave %d.",DspSV(foo),DspSV(foo),c D;
		++e;
	}
	Exit(e);
}
