简单的测试类,一些知识点


package yfTest.shixi;


import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;

import org.junit.BeforeClass;
import org.junit.Test;

public class junitTest {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}
	@Test
	/**
	 * 已经是采用的最优算法,可以看源代码,7位以下,7-40,40以上不同处理
	 */
	public void  SortTest(){
		  int[] iii={4,5,61,3,2,4};//,26,21,2,-82,34};
		  Arrays.sort(iii);
		  for (int i : iii) {
		   System.out.println(i);
		  }
	 }
	@Test
	public void DateFormatTest(){
		System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
	}
	@Test
	/**
	 * output:true
	 * 程序中 中文和字符都是占用两个字节
	 */
	public void VectorTest(){
		char[] c= "中文".toCharArray();
		System.out.println("中文".length()=="aa".length());
	}
	@Test
	/**
	 * 合并两个arraylist ,回答的别人的问题,留下来用
	 */
	public void arrayListAdd(){
	     ArrayList q1 = new ArrayList();
	     ArrayList q2 = new ArrayList();
	     ArrayList q3 = new ArrayList();
	     String str1 = "abcdefdef";
	     String str2 = "12345";
	     int len1= str1.length();
	     int len2= str2.length();
	     for(char c:str1.toCharArray())
	    	 q1.add(c);
	     for(char c:str2.toCharArray())
	    	 q2.add(c);
	     int max = len1>len2?len1:len2;
	     int min = len1<len2?len1:len2;
	     //以上均为初始化
	     //System.out.println(max+" "+min+q1+q2);
	     int i=0;
	     while(i<min){
	    	 q3.add(q1.get(i));
	    	 q3.add(q2.get(i));
	    	 i++;
	     }
	     while(i<max){
	    	 if(len1 == max){
	    		 q3.add(q1.get(i));
	    	 }else{
	    		 q3.add(q2.get(i));
	    	 }
	    	 i++;
	     }
	     System.out.println(q3);
	}
	@Test
	/**
	 * 断言
	 */
	public void AssertTest(){
		int count = 0;
		org.junit.Assert.assertFalse("this is ", 1 == 1);
		junit.framework.Assert.assertFalse("message", 1 == 1);
	}
	@Test
	public void CalenderTest(){
		Calendar now = Calendar.getInstance();
		System.out.println(now.get(Calendar.DAY_OF_MONTH));
		System.out.println(now.get(Calendar.DAY_OF_WEEK));
		System.out.println(now.get(Calendar.YEAR));
	}
}



你可能感兴趣的:(java,C++,c,C#,JUnit)