亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? treenodetest.java

?? 一套j2me的UI界面庫(kù)
?? JAVA
字號(hào):
package org.j4me.collections;

import j2meunit.framework.*;

/**
 * Tests the <code>TreeNode</code> object.  It is a generic tree (integer.e. not a balanced tree
 * or some other specialized tree).
 * 
 * @see org.j4me.collections.TreeNode
 */
public class TreeNodeTest
	extends TestCase
{
	public TreeNodeTest ()
	{
		super();
	}
	
	public TreeNodeTest (String name, TestMethod method)
	{
		super( name, method );
	}
	
	public Test suite ()
	{
		TestSuite suite = new TestSuite();
		
		suite.addTest(new TreeNodeTest("testIllegalOperations", new TestMethod() 
				{ public void run(TestCase tc) {((TreeNodeTest) tc).testIllegalOperations(); } }));
		suite.addTest(new TreeNodeTest("testUserObjects", new TestMethod() 
				{ public void run(TestCase tc) {((TreeNodeTest) tc).testUserObjects(); } }));
		suite.addTest(new TreeNodeTest("testRoot", new TestMethod() 
				{ public void run(TestCase tc) {((TreeNodeTest) tc).testRoot(); } }));
		suite.addTest(new TreeNodeTest("testOneChild", new TestMethod() 
				{ public void run(TestCase tc) {((TreeNodeTest) tc).testOneChild(); } }));
		suite.addTest(new TreeNodeTest("testMultipleChildren", new TestMethod() 
				{ public void run(TestCase tc) {((TreeNodeTest) tc).testMultipleChildren(); } }));
		suite.addTest(new TreeNodeTest("testMultipleLevels", new TestMethod() 
				{ public void run(TestCase tc) {((TreeNodeTest) tc).testMultipleLevels(); } }));
		suite.addTest(new TreeNodeTest("testBigTree", new TestMethod() 
				{ public void run(TestCase tc) {((TreeNodeTest) tc).testBigTree(); } }));
		
		return suite;
	}
	
	/**
	 * Tests the tree nodes defend themselves again invalid parameters that would
	 * be the result of programming errors.
	 */
	public void testIllegalOperations ()
	{
		// Test cannot add a child node to position greater than available number of children.
		boolean caughtException = false;
		
		try
		{
			TreeNode root = new TreeNode();
			root.add( new TreeNode(), 1 );
		}
		catch (IllegalArgumentException e)
		{
			caughtException = true;
		}
		catch (Throwable t)
		{
			String actualExceptionName = t.getClass().getName();
			fail( "Expected exception 'IllegalArgumentException' and got '" + actualExceptionName + "'." );
		}
		
		if ( caughtException == false )
		{
			fail( "Expected exception 'IllegalArgumentException' but no exceptions caught." );
		}
		
		
		// Test remove a child node from position greater than available number of children.
		caughtException = false;
		
		try
		{
			TreeNode root = new TreeNode();
			root.remove( 1 );
		}
		catch (IllegalArgumentException e)
		{
			caughtException = true;
		}
		catch (Throwable t)
		{
			String actualExceptionName = t.getClass().getName();
			fail( "Expected exception 'IllegalArgumentException' and got '" + actualExceptionName + "'." );
		}
		
		if ( caughtException == false )
		{
			fail( "Expected exception 'IllegalArgumentException' but no exceptions caught." );
		}
	}
	
	/**
	 * Tests that user objects can be attached and extracted from
	 * a tree node.
	 */
	public void testUserObjects ()
	{
		String user = "This is a test string.\n  It should go in and come out the same.";
		Integer user2 = new Integer(13);
		
		// Create a node with the user defined object.
		TreeNode node = new TreeNode( user );
		
		// Get the object back out.
		Object obj = node.getUserObject();
		String result = (String)obj;
		assertEquals("The attached string should be the same one as put in.", user, result);
		
		// Try erasing the string.
		node.setUserObject( null );
		obj = node.getUserObject();
		assertNull("No user object should be attached to the node.", obj);
		
		// Put a different object back in and pull it out.
		node.setUserObject( user2 );
		obj = node.getUserObject();
		Integer intResult = (Integer)obj;
		assertEquals("The attached Integer should be the same one as put in.", user2, intResult);
	}
	
	/**
	 * Tests assertions about a root node.  This is a very simple test
	 * and should be right before working with children.
	 */
	public void testRoot ()
	{
		TreeNode root = new TreeNode();
		
		// Verify properties of the root node.
		boolean isRoot = root.isRoot();
		assertTrue("The node should be the root node.", isRoot);
		
		int index = root.index();
		assertEquals("The root node should have an index of -1 since it has no parent.", -1, index);
		
		int depth = root.depth();
		assertEquals("The root node should have depth of 0 since it has no parent.", 0, depth);
		
		TreeNode parent = root.getParent();
		assertNull("The root node should not have a parent node.", parent);
		
		boolean hasChildren = root.hasChildren();
		assertTrue("The root node should not have any children because none have been added.", hasChildren == false);
		
		TreeNode[] children = root.children();
		int childLength = children.length;
		assertEquals("The root node should not have any children because none have been added.", 0, childLength);
		
		// Verify the following method doesn't throw an exception.
		root.removeFromParent();
	}
	
	/**
	 * Test a tree that has a root and just one child.  This is a simple
	 * test to verify the child has properties appropriately set before
	 * testing more complex trees.
	 */
	public void testOneChild ()
	{
		// Create the tree.
		TreeNode root = new TreeNode();
		TreeNode child = new TreeNode();
		root.add( child );
		
		// Verify properties of the child node.
		boolean isRoot = child.isRoot();
		assertTrue("The node should not be the root node.", isRoot == false);
		
		int index = child.index();
		assertEquals("The child node should have an index of 0 since it is the only child.", 0, index);
		
		int depth = child.depth();
		assertEquals("The child node should have depth of 1 since it is a first level node.", 1, depth);
		
		TreeNode parent = child.getParent();
		assertEquals("The child's parent should be the root node.", root, parent);
		
		boolean hasChildren = child.hasChildren();
		assertTrue("The child node should not have any children because none have been added.", hasChildren == false);
		
		hasChildren = root.hasChildren();
		assertTrue("The root node should now have children.", hasChildren == true);
		
		TreeNode[] children = child.children();
		int childLength = children.length;
		assertEquals("The child node should not have any children because none have been added.", 0, childLength);
		
		children = root.children();
		childLength = children.length;
		assertEquals("The root node should have 1 child.", 1, childLength);

		TreeNode theChild = children[0];
		assertEquals("The root's child should be child.", child, theChild);
		
		// Now remove the child from the root.
		child.removeFromParent();
		
		isRoot = child.isRoot();
		assertTrue("The child node should now be the root of its own subtree.", isRoot == true);
		
		depth = child.depth();
		assertEquals("The child node should have depth of 0 since it is now the root.", 0, depth);
		
		parent = child.getParent();
		assertEquals("The child should not have a parent since it is now the root.", null, parent);
		
		hasChildren = root.hasChildren();
		assertTrue("The root node should no longer have any children.", hasChildren == false);
	}

	/**
	 * This tests a tree only 1 level deep, but there are several first
	 * level children.  This is useful to test that siblings are kept
	 * correctly before testing multiple level trees.
	 */
	public void testMultipleChildren ()
	{
		TreeNode root = new TreeNode();
		TreeNode child1 = new TreeNode();
		TreeNode child2 = new TreeNode();
		TreeNode child3 = new TreeNode();
		
		// Add the children.
		root.add( child1, 0 );
		root.add( child3, 1 );  // Add with index, but really appending child
		root.add( child2, 1 );  // Add out of order to test insertion in the middle of the children
		
		TreeNode[] children = root.children();
		assertEquals("child1 should be the first child.", child1, children[0]);
		assertEquals("child2 should be the second child.", child2, children[1]);
		assertEquals("child3 should be the third child.", child3, children[2]);
		
		// Verify the properties of the children.
		for ( int i = 0; i < children.length; i++ )
		{
			TreeNode child = children[i];
			
			int index = child.index();
			assertEquals("child" + (i+1) + " should have an index of " + i, i, index);
			
			boolean isRoot = child.isRoot();
			assertTrue("child" + (i+1) + " should not be the root node.", isRoot == false);
			
			int depth = child.depth();
			assertEquals("child" + (i+1) + " should have depth of 1 since it is a first level node.", 1, depth);
			
			TreeNode parent = child.getParent();
			assertEquals("child" + (i+1) + "'s parent should be the root node.", root, parent);
			
			boolean hasChildren = child.hasChildren();
			assertTrue("child" + (i+1) + " should not have any children because none have been added.", hasChildren == false);
		}
		
		// Remove the middle child.
		TreeNode removed = root.remove( 1 );
		assertEquals("The removed node should be child2.", child2, removed);
		assertEquals("child2 should now have a depth of 0.", 0, removed.depth());
		
		children = root.children();
		assertEquals("The root should now have 2 children.", 2, children.length);
		assertEquals("child3 should be the second child.", child3, children[1]);
		
		// Add the middle child back in.
		root.add( removed, 1 );
		children = root.children();
		TreeNode node = children[1];

		assertEquals("The second node should be child2 again.", child2, node);
		assertEquals("child2's parent should be the root again.", root, child2.getParent());
		assertEquals("child2's depth should be 1 again.", 1, child2.depth());
		
		// Remove all the children.
		root.remove( 1 );
		root.remove( 1 );
		child1.removeFromParent();
		assertTrue("The root should not have any children now.", root.hasChildren() == false);
	}
	
	/**
	 * This tests that multiple levels of the tree work correctly.  Each
	 * level has only 1 child.  This is a simple test to verify depth
	 * works before moving onto more complex trees.
	 */
	public void testMultipleLevels ()
	{
		TreeNode root = new TreeNode();
		TreeNode depth1 = new TreeNode();
		TreeNode depth2 = new TreeNode();
		TreeNode depth3 = new TreeNode();
		
		// Add the children.
		root.add( depth1 );
		depth2.add( depth3 );
		depth1.add( depth2 );

		// Verify the properties of the nodes.
		assertTrue("The root should have 1 child.", root.hasChildren() == true);
		assertEquals("The root should have a depth of 0.", 0, root.depth());
		assertEquals("The root should not have a parent.", null, root.getParent());
		
		assertTrue("depth1 should have 1 child.", depth1.hasChildren() == true);
		assertEquals("depth1 should have a depth of 1.", 1, depth1.depth());
		assertEquals("depth1 should have root as its parent.", root, depth1.getParent());
		
		assertTrue("depth2 should have 1 child.", depth2.hasChildren() == true);
		assertEquals("depth2 should have a depth of 2.", 2, depth2.depth());
		assertEquals("depth2 should have depth1 as its parent.", depth1, depth2.getParent());
		
		assertTrue("depth3 should have not have any children.", depth3.hasChildren() == false);
		assertEquals("depth3 should have a depth of 3.", 3, depth3.depth());
		assertEquals("depth3 should have depth2 as its parent.", depth2, depth3.getParent());
		
		// Cut the tree in 1/2.
		depth2.removeFromParent();
		assertTrue("depth2 should now be a root.", depth2.isRoot() == true);
		assertEquals("depth2 should now have a depth of 0.", 0, depth2.depth());
		assertEquals("depth3 should now have a depth of 1.", 1, depth3.depth());
		assertTrue("depth1 should not have any children now.", depth1.hasChildren() == false);
	}
	
	/**
	 * This tests a tree with multiple varying depths and multiple
	 * varying amounts of children at each depth.
	 */
	public void testBigTree ()
	{
		String testData = "";
		
		TreeNode root = new TreeNode();
		TreeNode d1c0 = new TreeNode( testData );
		TreeNode d1c1 = new TreeNode( testData );
		TreeNode d1c2 = new TreeNode( testData );
		TreeNode d2c1c0 = new TreeNode( testData );
		TreeNode d2c1c1 = new TreeNode( testData );
		TreeNode d2c1c2 = new TreeNode( testData );
		TreeNode d2c2c0 = new TreeNode( testData );
		TreeNode d2c2c1 = new TreeNode( testData );
		TreeNode d3c2c0c0 = new TreeNode( testData );
		TreeNode d3c2c0c1 = new TreeNode( testData );
		
		root.add( d1c0 );
		root.add( d1c1 );
		root.add( d1c2 );
		
		d1c1.add( d2c1c1 );  // Second child
		d1c1.add( d2c1c0, 0 );  // First child
		d1c1.add( d2c1c2 );  // Third child
		
		d1c2.add( d2c2c0 ); 
		d2c2c0.add( d3c2c0c0 );
		d2c2c0.add( d3c2c0c1 );

		d1c2.add( d2c2c1 ); 
		
		// Verify the tree structure.
		assertEquals("root should be the parent of d1c0", root, d1c0.getParent());
		assertEquals("root should be the parent of d1c1", root, d1c1.getParent());
		assertEquals("root should be the parent of d1c2", root, d1c2.getParent());
		
		assertEquals("d1c1 should be the parent of d2c1c0", d1c1, d2c1c0.getParent());
		assertEquals("d1c1 should be the parent of d2c1c1", d1c1, d2c1c1.getParent());
		assertEquals("d1c1 should be the parent of d2c1c2", d1c1, d2c1c2.getParent());
		
		assertEquals("d1c2 should be the parent of d2c2c0", d1c2, d2c2c0.getParent());
		assertEquals("d1c2 should be the parent of d2c2c1", d1c2, d2c2c1.getParent());
		
		assertEquals("d2c2c0 should be the parent of d3c2c0c0", d2c2c0, d3c2c0c0.getParent());
		assertEquals("d2c2c0 should be the parent of d3c2c0c1", d2c2c0, d3c2c0c1.getParent());
		
		// Verify the depths of some of the nodes.
		assertEquals("root should have a depth of 0", 0, root.depth());
		assertEquals("d1c1 should have a depth of 1", 1, d1c1.depth());
		assertEquals("d2c2c0 should have a depth of 2", 2, d2c2c0.depth());
		assertEquals("d3c2c0c1 should have a depth of 3", 3, d3c2c0c1.depth());
		
		// Verify we can traverse the tree from root to d3c2c0c0.
		TreeNode node = root.children()[2];  // d1c2
		node = node.children()[0];  // d2c2c0
		node = node.children()[0];  // d3c2c0c0
		assertEquals("We should have tranversed the tree to d3c2c0c0.", d3c2c0c0, node);
		
		assertEquals("Should have test data as user object from node d3c2c0c0.", testData, node.getUserObject());
	}
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久九九九九| 欧美性猛片aaaaaaa做受| 亚洲综合无码一区二区| 欧美精选在线播放| 日韩精品资源二区在线| 国产欧美精品区一区二区三区| 亚洲精品一区二区三区香蕉| 国产精品视频免费看| 一个色在线综合| 麻豆91在线观看| 成人精品亚洲人成在线| 91麻豆6部合集magnet| 91精品国产色综合久久久蜜香臀| 久久久不卡网国产精品二区| 中文字幕在线免费不卡| 五月婷婷久久综合| 国产在线日韩欧美| 成人精品高清在线| 精品视频一区 二区 三区| 日韩限制级电影在线观看| 精品久久久久av影院| 国产精品免费网站在线观看| 久久亚洲二区三区| 亚洲一区二区三区国产| 免费视频一区二区| 91在线云播放| 欧美一区二区美女| 亚洲欧美日韩国产综合在线| 成人看片黄a免费看在线| 欧美视频一区二区三区四区| 国产欧美一区二区精品婷婷 | 91精品国产91久久久久久一区二区| 91精品国产91久久久久久一区二区| 国产女人aaa级久久久级 | 精品国产乱子伦一区| 玉米视频成人免费看| av一本久道久久综合久久鬼色| 91丝袜高跟美女视频| 日韩理论在线观看| 国产精品一区二区久激情瑜伽| 黄色资源网久久资源365| 欧美无砖砖区免费| 一区二区三区四区中文字幕| 色婷婷综合中文久久一本| 久久久电影一区二区三区| 欧美三级韩国三级日本一级| 亚洲国产成人私人影院tom| 午夜精品福利一区二区三区蜜桃| 成人app在线| 欧美精品一区二区久久久| 亚洲福利一区二区| 91丨九色porny丨蝌蚪| 久久精品欧美一区二区三区不卡 | 成人国产精品免费| 精品国产乱码久久久久久图片| 亚洲小说春色综合另类电影| 国产欧美日韩麻豆91| 精品制服美女久久| 久久精品人人做人人爽人人| 国产不卡在线视频| 欧美国产激情二区三区| 国产精品中文字幕日韩精品| 日韩欧美色电影| 免费在线观看不卡| 成人综合婷婷国产精品久久| 欧美大片一区二区三区| 亚洲精品国产一区二区精华液 | 国产九九视频一区二区三区| 欧美精品一级二级三级| 一区二区三区免费看视频| 国产精品888| 欧美国产禁国产网站cc| 国产ts人妖一区二区| 国产日韩欧美一区二区三区乱码 | 欧美性色黄大片手机版| 亚洲九九爱视频| 欧美性视频一区二区三区| 久久人人超碰精品| 日本亚洲天堂网| 久久你懂得1024| 玖玖九九国产精品| 午夜精品成人在线视频| 欧美系列在线观看| 国产欧美一区二区精品仙草咪| 国产在线精品国自产拍免费| 欧美一区二区三区啪啪| 亚洲成av人在线观看| 欧美调教femdomvk| 亚洲一区二区精品视频| 在线看不卡av| 亚洲精品成人少妇| 国产盗摄女厕一区二区三区| 久久众筹精品私拍模特| 狠狠色狠狠色综合日日91app| 欧美成人三级在线| 国产在线视视频有精品| 久久久久久久久久久久电影 | 欧美电影免费观看高清完整版| 蜜桃精品视频在线| 一区精品在线播放| 欧美一区二区播放| 成人激情午夜影院| 午夜电影一区二区三区| 精品国产污网站| www.99精品| 日韩国产高清在线| 亚洲色图一区二区三区| 日韩三级在线免费观看| 精一区二区三区| 亚洲国产你懂的| 中文字幕一区二区三区av | 欧美韩国一区二区| 成人精品国产一区二区4080| 亚洲图片欧美视频| 精品国产亚洲一区二区三区在线观看| 91首页免费视频| 国产一区二区免费在线| 亚洲成人资源网| 欧美高清在线视频| 在线免费观看一区| 99免费精品视频| 91国产视频在线观看| 成人高清免费观看| 欧美人狂配大交3d怪物一区| 日日摸夜夜添夜夜添国产精品| 久久久久九九视频| 欧美一级日韩免费不卡| 黄页视频在线91| 成人蜜臀av电影| 欧美日韩国产综合一区二区三区| 亚洲特级片在线| 欧美经典一区二区三区| av在线播放一区二区三区| 亚洲精品久久久久久国产精华液| 欧美一卡二卡三卡四卡| 成人福利电影精品一区二区在线观看 | 成人av先锋影音| 亚洲人成伊人成综合网小说| 欧美高清激情brazzers| 亚洲第一电影网| 91精品国产综合久久精品| 国产成人精品一区二区三区四区| 久久精品男人的天堂| 欧美系列在线观看| 国产成人亚洲综合a∨婷婷| 亚洲人成亚洲人成在线观看图片| 波多野结衣一区二区三区 | 亚洲成人一区在线| 美女视频黄a大片欧美| 国产剧情av麻豆香蕉精品| 国产东北露脸精品视频| 色天使色偷偷av一区二区| 在线播放亚洲一区| 宅男在线国产精品| 在线成人高清不卡| 久久久不卡影院| 亚洲狠狠丁香婷婷综合久久久| 亚洲精品免费看| 美女脱光内衣内裤视频久久影院| 激情综合色播五月| 91美女片黄在线观看| 欧美va亚洲va| 午夜精品视频一区| www.在线成人| 精品动漫一区二区三区在线观看| 亚洲婷婷在线视频| 精品一区二区久久久| 成人一道本在线| 777色狠狠一区二区三区| av高清久久久| 成人h动漫精品一区二| 欧美精品九九99久久| 亚洲欧美日本韩国| 亚洲欧洲精品成人久久奇米网| 色哟哟一区二区三区| 美腿丝袜一区二区三区| 又紧又大又爽精品一区二区| 欧美一区三区二区| 色婷婷综合久久久中文字幕| 国产成人亚洲综合a∨婷婷| 美女网站在线免费欧美精品| 亚洲国产欧美在线| 亚洲美女精品一区| 亚洲午夜激情av| 一区二区欧美国产| 1024成人网| 欧美α欧美αv大片| 国产91露脸合集magnet | 一区二区三区.www| 亚洲乱码一区二区三区在线观看| 5858s免费视频成人| 欧美性受xxxx黑人xyx性爽| 91免费看`日韩一区二区| 成人激情小说网站| 国产成人精品一区二区三区四区| 天天综合网 天天综合色| 亚洲精品欧美专区| 欧美不卡一区二区三区四区| 色94色欧美sute亚洲线路一ni| 99久久精品免费观看|