/*
 * LOGICAL-PARADOX.ORG
 * Copyright (C)2005 satoshi akabane(akabane@logical-paradox.org)
 * $Id: LocationTest.java,v 1.2 2005/05/31 14:38:20 rampil Exp $
 */
package org.logical_paradox.koike.core.summary;

import java.util.ArrayList;
import java.util.Collections;

import junit.framework.TestCase;

/**
 * DefaultSummaryGenerator.Locationクラスのテスト
 * @author satoshi akabane@logical-paradox.org
 * @version $Revision: 1.2 $
 */
public class LocationTest extends TestCase {

	/**
	 * Constructor for LocationTest.
	 * @param arg0
	 */
	public LocationTest(String arg0) {
		super(arg0);
	}
	/**
	 * setters/gettersの完全性テスト
	 */
	public void testObjectCorrectivity() {
		DefaultSummaryGenerator.Location location = new DefaultSummaryGenerator().new Location(100, "ああ", 4096);

		// 検索語種類番号
		assertEquals(100, location.index);
		// 検索語
		assertEquals("ああ", location.term);
		// 位置
		assertEquals(4096, location.pos);
	}
	/**
	 * ソートオーダーのテスト
	 * Collections.sort()した場合に，昇順にソートされること
	 */
	public void testSortOrder() {
		ArrayList locations = new ArrayList();
		locations.add(new DefaultSummaryGenerator().new Location(100, "ああ", 4096));
		locations.add(new DefaultSummaryGenerator().new Location(105, "いい", 99));
		locations.add(new DefaultSummaryGenerator().new Location(12, "うう", 23));
		locations.add(new DefaultSummaryGenerator().new Location(9, "ええ", 105));
		locations.add(new DefaultSummaryGenerator().new Location(-3, "おお", 102));

		// ソート
		Collections.sort(locations);

		assertEquals(23, ((DefaultSummaryGenerator.Location)locations.get(0)).pos);
		assertEquals(99, ((DefaultSummaryGenerator.Location)locations.get(1)).pos);
		assertEquals(102, ((DefaultSummaryGenerator.Location)locations.get(2)).pos);
		assertEquals(105, ((DefaultSummaryGenerator.Location)locations.get(3)).pos);
		assertEquals(4096, ((DefaultSummaryGenerator.Location)locations.get(4)).pos);
	}
}
