(*

Title:  TestVectors
Author: William M. Farmer
Revised: 03-OCT-2002
  
Description: Tests the module Vectors.

Interface:

INTERFACE TestVectors;
END TestVectors.

*)


MODULE TestVectors;

IMPORT Out, Vectors;

(* Basic Test Procedure *)

PROCEDURE TestCompare(x1,y1,x2,y2: REAL; z: INTEGER);
BEGIN
  Out.String("Compare(");
  Out.Real(x1);
  Out.String(",");
  Out.Real(y1);
  Out.String(",");
  Out.Real(x2);
  Out.String(",");
  Out.Real(y2);
  Out.String(")=");
  Out.Int(Vectors.Compare(x1,y1,x2,y2),0);
  Out.String("; the answer should be ");
  Out.Int(z,0);
  Out.String(".");
  Out.Ln
END TestCompare;

(* The Test *)

BEGIN

  Out.String("Test of the procedure Vectors.Compare:"); Out.Ln;

  (* Case 0 (identical) tests *)
  TestCompare(0,0,0,0,0);
  TestCompare(4.5,-6.1,4.5,-6.1,0);

  (* Case 1 (orthogonal) tests *)
  TestCompare(0,0,51,17,1);
  TestCompare(0,1,1,0,1);
  TestCompare(-1,1,-1,-1,1);

  (* Case 2 (collinear) tests *)
  TestCompare(4,0,1,0,2);  
  TestCompare(0,1,0,-7,2);  
  TestCompare(1,3,-0.5,-1.5,2);

  (* Case 3 (not identical, orthogonal, or collinear) tests *)
  TestCompare(1,3,-0.5,1.5,3);
  TestCompare(2,3,2,5,3);
  TestCompare(0,3,1,1,3);
  TestCompare(1,1,0,3,3);
  TestCompare(3,0,1,1,3);
  TestCompare(1,1,3,0,3);
  
END TestVectors.

