/*
 PathResolver_Test.java - Tester for PathResolver
 
 Copyright  (C) 2004-2005 Hugues Johnson
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 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 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.
 */

package com.huguesjohnson.test;

import java.lang.String;
import java.lang.System;
import com.huguesjohnson.PathResolver;

/**
 * PathResolver_Test - Tester for PathResolver
 * @author Hugues Johnson
 */
public class PathResolver_Test{

	/**
	 * Entry point for the test.
	 * @param arguments Not Used.
	 */
	public static void main(String[] arguments){
		boolean allPassed=true;

		String absolutePath1="c:\\folder1\\";
		String absolutePath2="c:\\folder1\\sub-folder1\\";
		String expectedRelativePath=".\\sub-folder1\\";
		String actualPath=PathResolver.getRelativePath(absolutePath1,absolutePath2);
		if(!expectedRelativePath.equalsIgnoreCase(actualPath)){
			allPassed=false;
			System.out.println("expectedRelativePath="+expectedRelativePath);
			System.out.println("actualPath="+actualPath);
			System.out.println("");
		}

		absolutePath1="c:\\folder1\\sub-folder1\\";
		absolutePath2="c:\\folder2\\";
		expectedRelativePath="..\\..\\folder2\\";
		actualPath=PathResolver.getRelativePath(absolutePath1,absolutePath2);
		if(!expectedRelativePath.equalsIgnoreCase(actualPath)){
			allPassed=false;
			System.out.println("expectedRelativePath="+expectedRelativePath);
			System.out.println("actualPath="+actualPath);
			System.out.println("");
		}

		absolutePath1="c:\\folder1\\";
		absolutePath2="d:\\folder2\\";
		expectedRelativePath="d:\\folder2\\";
		actualPath=PathResolver.getRelativePath(absolutePath1,absolutePath2);
		if(!expectedRelativePath.equalsIgnoreCase(actualPath)){
			allPassed=false;
			System.out.println("expectedRelativePath="+expectedRelativePath);
			System.out.println("actualPath="+actualPath);
			System.out.println("");
		}

		absolutePath1="D:\\Projects\\com\\huguesjohnson\\";
		absolutePath2="D:\\Projects\\com\\huguesjohnson\\tiamat\\demos\\";
		expectedRelativePath=".\\tiamat\\demos\\";
		actualPath=PathResolver.getRelativePath(absolutePath1,absolutePath2);
		if(!expectedRelativePath.equalsIgnoreCase(actualPath)){
			allPassed=false;
			System.out.println("expectedRelativePath="+expectedRelativePath);
			System.out.println("actualPath="+actualPath);
			System.out.println("");
		}

		absolutePath1="D:\\Projects\\com\\huguesjohnson\\tiamat\\demos\\";
		absolutePath2="D:\\";
		expectedRelativePath="..\\..\\..\\..\\..\\";
		actualPath=PathResolver.getRelativePath(absolutePath1,absolutePath2);
		if(!expectedRelativePath.equalsIgnoreCase(actualPath)){
			allPassed=false;
			System.out.println("expectedRelativePath="+expectedRelativePath);
			System.out.println("actualPath="+actualPath);
			System.out.println("");
		}

		absolutePath1="D:\\Projects\\com\\huguesjohnson\\tiamat\\demos\\";
		absolutePath2="D:\\Graphics\\Counters\\";
		expectedRelativePath="..\\..\\..\\..\\..\\Graphics\\Counters\\";
		actualPath=PathResolver.getRelativePath(absolutePath1,absolutePath2);
		if(!expectedRelativePath.equalsIgnoreCase(actualPath)){
			allPassed=false;
			System.out.println("expectedRelativePath="+expectedRelativePath);
			System.out.println("actualPath="+actualPath);
			System.out.println("");
		}

		absolutePath1="D:\\Projects\\com\\huguesjohnson\\tiamat\\demos\\ps3\\";
		absolutePath2="D:\\Projects\\com\\huguesjohnson\\hapsby\\";
		expectedRelativePath="..\\..\\..\\hapsby\\";
		actualPath=PathResolver.getRelativePath(absolutePath1,absolutePath2);
		if(!expectedRelativePath.equalsIgnoreCase(actualPath)){
			allPassed=false;
			System.out.println("expectedRelativePath="+expectedRelativePath);
			System.out.println("actualPath="+actualPath);
			System.out.println("");
		}

		String absolutePath="c:\\folder1\\";
		String relativePath=".\\sub-folder1\\";
		String expectedAbsolutePath="c:\\folder1\\sub-folder1\\";
		actualPath=PathResolver.getAbsolutePath(absolutePath,relativePath);
		if(!expectedAbsolutePath.equalsIgnoreCase(actualPath)){
			allPassed=false;
			System.out.println("expectedAbsolutePath="+expectedAbsolutePath);
			System.out.println("actualPath="+actualPath);
			System.out.println("");
		}

		absolutePath="c:\\folder1\\sub-folder1\\";
		relativePath="..\\..\\folder2\\";
		expectedAbsolutePath="c:\\folder2\\";
		actualPath=PathResolver.getAbsolutePath(absolutePath,relativePath);
		if(!expectedAbsolutePath.equalsIgnoreCase(actualPath)){
			allPassed=false;
			System.out.println("expectedAbsolutePath="+expectedAbsolutePath);
			System.out.println("actualPath="+actualPath);
			System.out.println("");
		}

		absolutePath="D:\\Projects\\com\\huguesjohnson\\tiamat\\demos\\ps3\\";
		relativePath="..\\..\\..\\hapsby\\";
		expectedAbsolutePath="D:\\Projects\\com\\huguesjohnson\\hapsby\\";
		actualPath=PathResolver.getAbsolutePath(absolutePath,relativePath);
		if(!expectedAbsolutePath.equalsIgnoreCase(actualPath)){
			allPassed=false;
			System.out.println("expectedAbsolutePath="+expectedAbsolutePath);
			System.out.println("actualPath="+actualPath);
			System.out.println("");
		}

		if(allPassed){
			System.out.println("Good times");
		} else{
			System.out.println("Bad times");
		}

		System.exit(0);
	}
}