全国大学生软件测试大赛参赛记录分享

全国大学生软件测试大赛

软件测试大赛是由南京大学陈振宇教授主持举办的。有幸能和院长老师,也是我的软件测试课程的老师参加了第四届软件测试开发者个人总决赛

目录

2019第四届

秋季预选赛

省赛

总决赛

2019年第四届

大三上学期拉开了帷幕,软件测试课程老师让我们两个班级的同学参加这个全国大学生软件测试,主要是参加开发者和嵌入式这两个分赛项。我们也是对这个比赛毫无概念,之前也没有接触过关于软件测试的相关知识,老师平时在慕测平台上发布一些题目,我们完全没有头脑,心里暗暗地想着,What?这是什么,我也就照着老师讲的一个Triangle例题,想着难道开发者测试就是调用函数吗?就这样我就创建类的对象,然后用这个对象调用函数呗!

由于比赛时间和我暑假一直准备的全国大学生数学竞赛10月26日上午产生了冲突,内心纠结是参加这个还是参加数学竞赛,最终由于软件测试大赛与课程期末分数息息相关,我决定参加软件测试大赛。

很快到了国庆节,我决定不回家了,就在宿舍里宅了一周,每天花费2个小时做老师留的9个开发者练习题,一天做一个。哧溜一下国庆假期结束了,第一天上课,老师说“这些天就一个叫做 ‘#洁’ 的同学做的练习题最多,分数我看都接近满分了”,我一听嗯? 两个班级的同学我都认识啊,没听过有叫’#洁’的啊,况且’#‘是独姓,然后就有同学说是’#浩’**,嘿嘿嘿,这个名字被人叫错不下于10次了,老师说好,过两天请“#浩”同学给我们讲一讲练习题。下课了,我蒙皮地找到老师说:“老师我不行啊,我也不会啊”,老师说没事:“这几天好好准备,把你怎么做的讲出来就行”。

好吧!蒙皮的我回去疯狂查资料了解我应该怎么讲,甚至我还准备了小纸条。
我讲述的题目:SuffixArray后缀数组。我准备的小纸条:

从某个位置开始到整个串末尾结束子串 aabaaaab sa[i]数组存放排名第i的后缀的首字符在原字符串中的下标,排名第i的是谁?
rank[j]存放后缀的名次,j排第几? rank[sa[i]]=i; 这两个数组是互逆数组 构造sa数组利用倍增算法(每次排序长度*2)
基数排序: 73,22,93,43,55,14 先按照个位数,再按照百位数(0,1,2,3,4,5,6,7,8,9)

下面粘出我将给同学的一个例子SuffixArray

待测类

package net.mooctest;

import java.util.Arrays;
/**
 * @author lenovo
 *
 */
class SuffixArray
{
    //LCP:Longest common prefix
    /*字符串后缀,指从字符串某个
     * 位置开始到字符串末尾的字串,原串和空串也是后缀
     * Create the LCP array from the suffix array
     * 从后缀数组创建LCP数组
     * @param s the input array populated from 0..N-1, with available pos N
     * s为包含n个元素的输入数组
     * @param sa the already-computed suffix array 0..N-1
     * sa是已经计算出的后缀数组
     * @param LCP the resulting LCP array 0..N-1
     * LCP是得到的LCP数组     */
    public static void makeLCPArray( int [ ] s, int [ ] sa, int [ ] LCP )
    {
        int N = sa.length;
        int [ ] rank = new int[ N ];
        
        s[ N ] = -1;
        for( int i = 0; i < N; i++ )//s的n个后缀从小到大排序把排好序的后缀的开头位置放到sa中
            rank[ sa[ i ] ] = i;//sa[i]存放排名第i大的后缀首字符在原来字符串中的下标
        //rank[i]存放后缀的优先级,后缀在所有后缀中从小到大排列的名次
        //求出sa数组之后,根据rank[sa[i]]=i,sa[i]排第i名的是谁?,你排第几?
        //rank数组自然也就能够在O(n)的时间内求出
        int h = 0;
        for( int i = 0; i < N; i++ )
            if( rank[ i ] > 0 )
            {
                int j = sa[ rank[ i ] - 1 ];
                //j是i的按排名来的上一个字符串
                while( s[ i + h ] == s[ j + h ] )
                    h++;
                
                LCP[ rank[ i ] ] = h;//height就是lcp,i号后缀与它前一名的后缀的最长公共前缀
                if( h > 0 )
                    h--;
            }
    }
    //创建后缀数组,
    /*
     * Fill in the suffix array information for String str
     * 为字符串str创建后缀数组信息
     * @param str the input String
     * str位输入的字符串
     * @param sa existing array to place the suffix array
     * sa 用于放置后缀数组
     */
    public static void createSuffixArray( String str, int [ ] sa, int [ ] LCP )
    {        
        int N = str.length( );
        
        int [ ] s = new int[ N + 3 ];
        int [ ] SA = new int[ N + 3 ];
        
        for( int i = 0; i < N; i++ )
            s[ i ] = str.charAt( i );
        
        makeSuffixArray( s, SA, N, 256 );
        
        for( int i = 0; i < N; i++ )
            sa[ i ] = SA[ i ];
        
        makeLCPArray( s, sa, LCP );
    }
    
    //找到s的后缀数组SA
    // find the suffix array SA of s[0..n-1] in {1..K}^n
    // require s[n]=s[n+1]=s[n+2]=0, n>=2
    public static void makeSuffixArray( int [ ] s, int [ ] SA, int n, int K )
    {
        int n0 = ( n + 2 ) / 3;
        int n1 = ( n + 1 ) / 3;
        int n2 = n / 3;
        int t = n0 - n1;  // 1 iff n%3 == 1
        int n12 = n1 + n2 + t;

        int [ ] s12  = new int[ n12 + 3 ];
        int [ ] SA12 = new int[ n12 + 3 ];
        int [ ] s0   = new int[ n0 ];
        int [ ] SA0  = new int[ n0 ];
        // generate positions in s for items in s12
        // the "+t" adds a dummy mod 1 suffix if n%3 == 1
        //添加一个虚拟
        // at that point, the size of s12 is n12
        //此时s12的大小是n12
        for( int i = 0, j = 0; i < n + t; i++ )
            if( i % 3 != 0 )
                s12[ j++ ] = i;
        
        int K12 = assignNames( s, s12, SA12, n0, n12, K );
  
        computeS12( s12, SA12, n12, K12 );
        computeS0( s, s0, SA0, SA12, n0, n12, K );
        merge( s, s12, SA, SA0, SA12, n, n0, n12, t );
    }
    
    // Assigns the new supercharacter names.
    // At end of routine, SA will have indices into s, in sorted order
    //在程序的最后,SA将把指标按顺序放入s中
    // and s12 will have new character names
    // Returns the number of names assigned; note that if
    // this value is the same as n12, then SA is a suffix array for s12.
    //返回分配的名称数目;注意,如果这个值与n12相同,那么SA就是s12的后缀数组。
    private static int assignNames( int [ ] s, int [ ] s12, int [ ] SA12,
                                   int n0, int n12, int K )
    {
           // radix sort the new character trios
    	//基数排序新字符trios
        radixPass( s12 , SA12, s, 2, n12, K );
        radixPass( SA12, s12 , s, 1, n12, K );  
        radixPass( s12 , SA12, s, 0, n12, K );

          // find lexicographic names of triples
        //查找三元组的词典名
        int name = 0;
        int c0 = -1, c1 = -1, c2 = -1;
      
        for( int i = 0; i < n12; i++ )
        {
            if( s[ SA12[ i ] ] != c0 || s[ SA12[ i ] + 1 ] != c1
                                     || s[ SA12[ i ] + 2 ] != c2 )
            { 
                name++;
                c0 = s[ SA12[ i ] ];
                c1 = s[ SA12[ i ] + 1 ];
                c2 = s[ SA12[ i ] + 2 ];
            }
          
            if( SA12[ i ] % 3 == 1 )
                s12[ SA12[ i ] / 3 ]      = name;
            else
                s12[ SA12[ i ] / 3 + n0 ] = name; 
       }
      
       return name;
    }
    
    
    // stably sort in[0..n-1] with indices into s that has keys in 0..K
    // into out[0..n-1]; sort is relative to offset into s
    // uses counting radix sort
    /*
     	* 稳定排序在[0 . .n-1],其下标为s,键值为0..K为(0 . . n - 1);排序是
     	* 相对偏移到s使用计数基数排序
     */
    //基数排序
    private static void radixPass( int [ ] in, int [ ] out, int [ ] s, int offset,
                                  int n, int K ) 
    { 
        int [ ] count = new int[ K + 2 ];            // counter array
        
        for( int i = 0; i < n; i++ )
            count[ s[ in[ i ] + offset ] + 1 ]++;    // count occurences
        
        for( int i = 1; i <= K + 1; i++ )            // compute exclusive sums
            count[ i ] += count[ i - 1 ];

        for( int i = 0; i < n; i++ )
            out[ count[ s[ in[ i ] + offset ] ]++ ] = in[ i ];      // sort
    } 
    
    // stably sort in[0..n-1] with indices into s that has keys in 0..K
    // into out[0..n-1]
    // uses counting radix sort
    /*
     * 稳定排序在[0 . .n-1],其下标为s,键值为0..K进入[0 . .n-1]使用计数基数排序
     */
    private static void radixPass( int [ ] in, int [ ] out, int [ ] s, int n, int K ) 
    { 
        radixPass( in, out, s, 0, n, K );
    }
   

    // Compute the suffix array for s12, placing result into SA12
    //计算s12的后缀数组,将结果放入SA12
    private static void computeS12( int [ ] s12, int [ ] SA12, int n12, int K12 )
    {
        if( K12 == n12 ) // if unique names, don't need recursion
        				//如果是唯一的名称,则不需要递归
       
            for( int i = 0; i < n12; i++ )
                SA12[ s12[i] - 1 ] = i; 
        else
        {
            makeSuffixArray( s12, SA12, n12, K12 );
            // store unique names in s12 using the suffix array 
            //使用后缀数组在s12中存储唯一的名称
            for( int i = 0; i < n12; i++ )
                s12[ SA12[ i ] ] = i + 1;
        }
    }
    
    private static void computeS0( int [ ] s, int [ ] s0, int [ ] SA0, int [ ] SA12,
                               int n0, int n12, int K )
    {
        for( int i = 0, j = 0; i < n12; i++ )
            if( SA12[ i ] < n0 )
                s0[ j++ ] = 3 * SA12[ i ];
        
        radixPass( s0, SA0, s, n0, K );
    }
    
    
    // merge sorted SA0 suffixes and sorted SA12 suffixes
    //合并排序后的SA0后缀和排序后的SA12后缀
    private static void merge( int [ ] s, int [ ] s12,
                              int [ ] SA, int [ ] SA0, int [ ] SA12,
                              int n, int n0, int n12, int t )
    {      
        int p = 0, k = 0;
        
        while( t != n12 && p != n0 )
        {
            int i = getIndexIntoS( SA12, t, n0 ); // S12
            int j = SA0[ p ];                     // S0
            
            if( suffix12IsSmaller( s, s12, SA12, n0, i, j, t ) )
            { 
                SA[ k++ ] = i;
                t++;
            }
            else
            { 
                SA[ k++ ] = j;
                p++;
            }  
        } 
        
        while( p < n0 )
            SA[ k++ ] = SA0[ p++ ];
        while( t < n12 )
            SA[ k++ ] = getIndexIntoS( SA12, t++, n0 ); 
    }
    
    private static int getIndexIntoS( int [ ] SA12, int t, int n0 )
    {
        if( SA12[ t ] < n0 )
            return SA12[ t ] * 3 + 1;
        else
            return ( SA12[ t ] - n0 ) * 3 + 2;
    }
    
    private static boolean leq( int a1, int a2, int b1, int b2 )
      { return a1 < b1 || a1 == b1 && a2 <= b2; }
    
    private static boolean leq( int a1, int a2, int a3, int b1, int b2, int b3 )
      { return a1 < b1 || a1 == b1 && leq( a2, a3,b2, b3 ); }
    
    private static boolean suffix12IsSmaller( int [ ] s, int [ ] s12, int [ ] SA12,
                                             int n0, int i, int j, int t )
    {
        if( SA12[ t ] < n0 )  // s1 vs s0; can break tie after 1 character
            return leq( s[ i ], s12[ SA12[ t ] + n0 ],
                        s[ j ], s12[ j / 3 ] );
        else                  // s2 vs s0; can break tie after 2 characters
            return leq( s[ i ], s[ i + 1 ], s12[ SA12[ t ] - n0 + 1 ],
                        s[ j ], s[ j + 1 ], s12[ j / 3 + n0 ] );
    }

    public static void printV( int [ ]  a, String comment )//什么意思
    {
        System.out.print( comment + ":" );
        for( int x : a ) 
            System.out.print( x + " " );

        System.out.println( );
    }
    //是排列
    public static boolean isPermutation( int [ ] SA, int n )
    {
        boolean [ ] seen = new boolean [ n ];
        
        for( int i = 0; i < n; i++ )
            seen[ i ] = false;
        
        for( int i = 0; i < n; i++ )
            seen[ SA[ i ] ] = true;
        
        for( int i = 0; i < n; i++ )
            if( !seen[ i ] )
                return false;
        
        return true;
    }

    public static boolean sleq( int  [ ] s1, int start1, int [ ] s2, int start2 )
    {
        for( int i = start1, j = start2; ; i++, j++ )
        {
            if( s1[ i ] < s2[ j ] )
                return true;
            
            if( s1[ i ] > s2[ j ] )
                return false;
        }
    } 

    // Check if SA is a sorted suffix array for s
    //检查SA是否是s的已排序后缀数组
    public static boolean isSorted( int [ ] SA, int [ ] s, int n )
    {
        for( int i = 0; i < n-1; i++ )
            if( !sleq( s, SA[ i ], s, SA[ i + 1 ] ) )
                return false;
      
        return true;  
    }

    /*
     * Returns the LCP for any two strings
     	* 返回任意两个字符串的LCP
     */
    //计算s1和s2的最长公共前缀
    public static int computeLCP( String s1, String s2 )
    {
        int i = 0;
        
        while( i < s1.length( ) && i < s2.length( ) && s1.charAt( i ) == s2.charAt( i ) )
            i++;
        
        return i;
    }

    /*
     * Fill in the suffix array and LCP information for String str
           * 为字符串str填写后缀数组和LCP信息
     * @param str the input String
     * str为输入的字符串
     * @param SA existing array to place the suffix array
           *一个已存在的数组,用来放置后缀数组
     * @param LCP existing array to place the LCP information
           * 用于放置LCP信息的LCP现有数组
     * Note: Starting in Java 7, this will use quadratic space.
     */
    public static void createSuffixArraySlow( String str, int [ ] SA, int [ ] LCP )
    {
        if( SA.length != str.length( ) || LCP.length != str.length( ) )
            throw new IllegalArgumentException( );
        
        int N = str.length( );
        
        String [ ] suffixes = new String[ N ];
        for( int i = 0; i < N; i++ )
            suffixes[ i ] = str.substring( i );
        
        Arrays.sort( suffixes );
        
        for( int i = 0; i < N; i++ )
            SA[ i ] = N - suffixes[ i ].length( );
        
        LCP[ 0 ] = 0;
        for( int i = 1; i < N; i++ )
            LCP[ i ] = computeLCP( suffixes[ i - 1 ], suffixes[ i ] );//两个相邻后缀的最长公共前缀
    }
}

我写的测试代码

package net.mooctest;

import static org.junit.Assert.*;

import org.junit.Test;

public class SuffixArrayTest {

	@Test
	public void test() {
		SuffixArray test=new SuffixArray();
		String str="aaaaaaaaaa";
		String str1="a";
		int[] sa= {0,1,2,3,4,5,6,7,8,9,10};
		int[] LCP= {0,1,2,3,4,5,6,7,8,9,10};
		test.createSuffixArray(str, sa, LCP);
		test.printV(sa, str1);//这是什么意思
		test.isPermutation(sa, 10);
		//test.createSuffixArraySlow(str, sa, LCP);
		String Str1="ababababab";
		int[] sa1= {0,1,2,3,4,5,6,7,8,9,10};
		int[] LCP1= {0,1,2,3,4,5,6,7,8,9,10};
		test.createSuffixArray(Str1, sa1, LCP1);
		try {
			test.createSuffixArraySlow(Str1, sa1, LCP1);
		}catch(IllegalArgumentException e) {	
		}
		String str2="abcdefghij";
		int[] sa2= {0,1,2,3,4,5,6,7,8,9,10};
		int[] LCP2= {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14};
		test.createSuffixArray(str2, sa2, LCP2);
		int[] s1= {0,1,2,3,4,5,6,7,8,9};
		int[] s2= {0,0,0,0,0,0,0,0,0,0};
		int[] s3= {9,8,2,3,4,5,7,6,1,0};
		test.sleq(s1, 0, s2, 0);
		test.sleq(s2, 1, s1, 0);
		test.isSorted(s1, s3, 0);
		int[] SA= {0,1,2,3,4,5,6,7,8,9,9,10};
		test.isPermutation(SA, 10);
		String str3=str1;
		test.computeLCP(Str1, str2);
		test.computeLCP(str1, str1);
		
	}

}
讲完概念之后我一段一段代码演示,到最后我来了一句,见证奇迹的时候到了,加上这一句(最后三句)就能覆盖率达到100%了,为什么?问就是:miracle

预选赛

预选赛有两个题目:一个是OST(覆盖89分),另一个是Hotel(覆盖97分)。
以下是我写的暴力测试------

OST:
package net.mooctest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Random;
import java.util.TreeSet;
import org.junit.Test;
import net.mooctest.OST;
import static org.junit.Assert.*;
import org.junit.Before;
public class OSTTest {
    private static final int Integer = 0;
	@Test(timeout = 4000)
    public void test() {
    	OST<Integer> tree = new OST<>();
        TreeSet<Integer> set = new TreeSet<>();
        assertEquals(set.isEmpty(), tree.isEmpty());
        tree.add(26);
        tree.add(17);
        tree.add(41);
        tree.add(14);
        tree.add(21);
        tree.add(30);
        tree.add(47);
        tree.add(10);
        tree.add(16);
        tree.add(19);
        tree.add(22);
        tree.add(28);
        tree.add(38);
        tree.add(7);
        tree.add(12);
        tree.add(15);
        tree.add(20);
        tree.add(35);
        tree.add(39);
        tree.add(3);
        tree.add(3);
        
        Collection<Integer>list=new ArrayList<Integer>();
        Collection<Integer>list1=new ArrayList<Integer>();
        Collection<Integer>list2=new ArrayList<Integer>();
        Collection<Integer>list3=new ArrayList<Integer>();
        HashSet hashset= new HashSet();
        hashset.add(1);
        list.add(26);
        list.add(17);
        list.add(41);
        list.add(14);
        list.add(21);
        list.add(30);
        list.add(47);
        list.add(10);
        list.add(16);
        list.add(19);
        list.add(22);
        list.add(28);
        list.add(38);
        list.add(7);
        list.add(12);
        list.add(15);
        list.add(20);
        list.add(35);
        list.add(39);
        list.add(3);
        list.add(3);
        list2.add(39);
        list2.add(3);
        list2.add(3);
        list2.add(66);
        list2.add(77);
        list3.add(-1);
        assertEquals(true,tree.containsAll(list));
        assertEquals(true,tree.containsAll(list1));
        assertEquals(false,tree.containsAll(list2));
        assertEquals(true,tree.addAll(list2));
        assertEquals(false,tree.addAll(list));

        System.out.println(tree.retainAll(list));
        assertEquals(false,tree.addAll(list));
        assertEquals(false,tree.retainAll(list));
        assertEquals(true,tree.retainAll(list1));
        assertEquals(false,tree.retainAll(list2));
        assertEquals(false,tree.retainAll(list3));
        assertEquals(false,tree.retainAll(list));
        assertEquals(false,tree.retainAll(hashset));
        System.out.println("__________+++++");
        assertEquals(false,tree.removeAll(list));
        assertEquals(false,tree.removeAll(list2));
        assertEquals(false,tree.removeAll(list3));
        tree.removeAll(list3);
        tree.containsAll(list1);
        assertEquals(true,tree.isHealthy());
        Integer[] a= {1,2,3,4,5,6,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
        Integer[] array=tree.toArray(a);
        Integer[] a1= {1,2,3,4,};
        Integer[] array1=tree.toArray(a1);
        try {
        	 tree.add((Integer)(null));
        }catch(Exception e) {
        	assertEquals(NullPointerException.class,e.getClass());
        }
       
        tree.contains(3);
        System.out.println(tree.contains(4));
        //测试不存在
        assertEquals(false,tree.contains(4));
        //测试存在
        assertEquals(false,tree.contains(3));
        try {
        	tree.remove(null);
        }catch(Exception e) {
        	assertEquals(NullPointerException.class,e.getClass());
        }
        tree.remove(3); 
        
    }
    @Test(timeout = 4000)
    public void test1() {
    	OST<Integer> tree1 = new OST<>();
    	OST<Integer> tree_1 =new OST<>() ;
    	assertEquals(true,tree_1.isHealthy());
    	//tree1.remove(1);
    	assertEquals(-1,tree1.indexOf(1));
    	System.out.println(tree1.remove(1));
    	assertEquals(false,tree1.remove(1));
    	 tree1.add(26);
    	 tree1.indexOf(1);
         tree1.add(17);
         tree1.add(41);
         tree1.add(14);
         tree1.add(21);
         tree1.add(30);
         tree1.add(47);
         tree1.add(10);
         tree1.add(16);
         tree1.add(19);
         tree1.add(22);
         tree1.add(28);
         tree1.add(3);
         tree1.add(3);
         tree1.remove(26);
         tree1.remove(30);
         //
         Collection<Integer>list=new ArrayList<Integer>();
         Collection<Integer>list1=new ArrayList<Integer>();
         Collection<Integer>list2=new ArrayList<Integer>();
         Collection<Integer>list3=new ArrayList<Integer>();
         HashSet hashset= new HashSet();
         hashset.add(1);
         list.add(26);
         list.add(17);
         list.add(41);
         list.add(14);
         list.add(21);
         list.add(30);
         list.add(47);
         list.add(10);
         list.add(16);
         list.add(19);
         list.add(22);
         list.add(28);
         list.add(38);
         list.add(7);
         list.add(12);
         list.add(15);
         list.add(20);
         list.add(35);
         list.add(39);
         list.add(3);
         list.add(3);
         list2.add(39);
         list2.add(3);
         list2.add(3);
         list2.add(66);
         list2.add(77);
         list3.add(-1);
         System.out.println(tree1.remove(26));
         System.out.println(tree1.remove(30));
         assertEquals(false,tree1.remove(26));
         assertEquals(false,tree1.remove(30));
         
         try {
        	 tree1.get(-1);
         }catch(Exception e) {
        	 assertEquals(IndexOutOfBoundsException.class,e.getClass());
         }
         System.out.println(tree1.get(0));
         System.out.println(tree1.get(1));
         System.out.println(tree1.get(9));
         tree1.get(0);
         tree1.get(1);
         tree1.get(9);
         try {
        	 tree1.get(12);
         }catch(Exception e) {
        	 assertEquals(IndexOutOfBoundsException.class,e.getClass());
         }
         assertEquals((Integer)3,(Integer)tree1.get(0));
         assertEquals((Integer)10,(Integer)tree1.get(1));
         assertEquals((Integer)41,(Integer)tree1.get(9));
         Object[] array1=tree1.toArray();
         for(Object i:array1) {
        	 System.out.print(i+" ");
         }
         org.junit.Assert.assertArrayEquals(array1 ,tree1.toArray());
         
         try {
        	 tree1.indexOf((Integer)null);
         }catch(Exception e) {
        	 assertEquals(NullPointerException.class,e.getClass());
         }
         assertEquals(10,tree1.indexOf(47));
         assertEquals(-1,tree1.indexOf((Integer)-1));
         assertEquals(11,tree1.size());
         assertEquals(false,tree1.isEmpty());
         System.out.println();
         assertEquals(true,tree1.isHealthy());
         System.out.println("__________+++++");
         assertEquals(true,tree1.removeAll(list));
         assertEquals(false,tree1.removeAll(list2));
         assertEquals(false,tree1.removeAll(list3));

    }
    @Test(timeout = 4000)
    public void test2() {
    	OST<Integer> tree1 = new OST<>();
        tree1.add(17);
        
        tree1.clear();
        assertEquals(true,tree1.isEmpty());
    }
}

Hotel:
package net.mooctest;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class HotelTest {

    @Test(timeout = 4000)
    public void test1() {
        Hotel hotel = new Hotel();
        hotel.addRoom(RoomType.ADVANCED,122,7);
        hotel.addRoom(RoomType.ADVANCED,123,6);
        try {
        	hotel.addRoom(RoomType.ADVANCED,122,4);
        }catch(Exception e) {
        	assertEquals(IllegalArgumentException.class,e.getClass());
        }
        hotel.addRoom(RoomType.STANDARD,126,5);
        hotel.addRoom(RoomType.STANDARD,127,4);
        hotel.addRoom(RoomType.DELUXE,128,3);
        hotel.addRoom(RoomType.DELUXE,129,2);
        Manager m=new Manager();
    	m.checkIn(10, 128);
    
        //assertEquals(1,hotel.rooms.size());
        try {
        	hotel.removeRoomFromList(121);
        }catch(Exception e) {
        	assertEquals("java.lang.IllegalArgumentException: Room not Exist:121",e.toString());
        	//System.out.println(e);
        }
        hotel.removeRoomFromList(122);
        List<Room>list=hotel.getFreeRooms();
        hotel.main(null);
        try {
        	hotel.queryRoom(122);
        }catch(Exception e) {
        	//assertEquals("java.lang.IllegalArgumentException: Room not exist:122",e.toString());
        }
        hotel.queryRoom(123);
        hotel.printAllRoomsInfo();
    }@Test(timeout = 4000)
    public void test2() {
    	Product product1=new Product("aaa",10,10);
    	Product product2=new Product("bbb",10,10);
    	try {
    		product1.setPrice(0);
    	}catch(Exception e) {
    		//assertEquals(IllegalArgumentException.class+"Price cannot less than 0:0.0",e.getClass());
    	}
    	try {
    		product1.setPrice(12.0102);
    	}catch(Exception e) {
    		System.out.println(e);
    		//assertEquals("java.lang.IllegalArgumentException: Price's length is wrong: 12.0102",e.getCause().getMessage());
    	}
    	product1.setDiscount(0.9);
    	try {
    		product1.setDiscount(0.0);
    	}catch(Exception e) {
    		
    	}
    	try {
    		product1.setDiscount(2.0);
    	}catch(Exception e) {
    		
    	}
    	try {
    		product1.setDiscount(0.09191);
    	}catch(Exception e) {
    		
    	}
    	try {
    		product1.setName("aaaaaaaaaaaaaaaaaaaaaaaaaa");
    	}catch(Exception e) {
    		
    	}
    	try {
    		product1.setName("@@####*&&%%$");
    	}catch(Exception e) {
    		
    	}
    	try {
    		product1.setCount(0);
    	}catch(Exception e) {
    	}
    	System.out.println(product1.getInfo());
    	System.out.println(product2.getInfo());
    	System.out.println(product1.getPaymentPrice());
    	assertEquals(9.0,product1.getPaymentPrice(),0.000);
    }
    @Test(timeout = 4000)
    public void test3() {
    	Room room=new Room();
    	Room room1=new Room(122,RoomType.STANDARD,7,20.0);
    	room1.book();
    	room1.unsubscribe();
    	room1.checkIn();
    	room1.checkOut();
    	try {
    		room1.setRoomCode(000);
    	}catch(Exception e) {
    		
    	}
    	try {
    		room1.setRoomCode(-1);
    	}catch(Exception e) {
    	}
    	try {
    		room1.setRoomCode(22200);
    	}catch(Exception e) {
    		
    	}
    	room.setRoomCode(101);
    	try {
    		room.setType("th");
    	}catch(Exception e) {
    	}
    	try {
    		room.setCapacity(11);
    	}catch(Exception e) {
    	}
    	try {
    		room.setCapacity(-1);
    	}catch(Exception e) {
    	}
    	try {
    		room.setPrice(0);
    	}catch(Exception e) {
    	}
    	try {
    		room.setPrice(1.11011);
    	}catch(Exception e) {
    	}

    	assertEquals(0,room.getCapacity());
    }
    @Test(timeout = 4000)
    public void test4() {
    	Product product1=new Product("aaa",10,10);
    	Product product2=new Product("bbb",100,10);
    	Product product3=new Product("ccc",1000,10);
    	Product product4=new Product("ddd",10,10);
    	Product product5=new Product("eee",100,10);
    	Product product6=new Product("fff",100000,10);
    	Product product7=new Product("",10,10);
    	Product product8=null;
    	List<Product> products=new ArrayList();
    	products.add(product1);
    	products.add(product2);
    	products.add(product3);
    	products.add(product4);
    	products.add(product5);
    	products.add(product6);
    	Shop shop=new Shop();
    	shop.addProduct(product1);
    	shop.addProduct(product2);
    	shop.addProduct(product3);
    	shop.addProduct(product4);
    	shop.addProduct(product5);
    	shop.addProduct(product6);
    	shop.addProduct(product7);
    	shop.addProduct(product7);
    	//测试
    	shop.getAllProductsInfo();
    	assertEquals(0,shop.deletProduct(""));
    	try {
    		assertEquals(0,shop.deletProduct("th"));
        	System.out.println();
    	}catch(Exception e) {
    		
    	}
    	try {
    		shop.sellProduct("th", 0);
    	}catch(Exception e) {
    		
    	}
    	try {
    		shop.sellProduct("eee", 0);
    	}catch(Exception e) {
    		
    	}
    	try {
    		shop.sellProduct("eee", 11110);
    	}catch(Exception e) {
    		
    	}
    	System.out.println("))))))");
    	assertEquals(9,shop.sellProduct("eee", 1));
    	Product p=shop.updateProduct("aaa", 29, 0.3);
    	assertEquals(p,shop.updateProduct("aaa", 29, 0.3));
    	try {
    		shop.updateProduct("aaaa", 29, 0.3);
    	}catch(Exception e) {
    		
    	}
    	shop.getProductByName("aaa");
    	shop.getProductByName("dadd");
    	ShopKeeper s=new ShopKeeper();
    	s.setShop(shop);
    	s.showAllProducts();
    	Map<String, Integer> map=new HashMap();
    	Map<String, Integer> map1=new HashMap();
    	map.put("aaa", 1);
    	map.put("bbb", 2);
    	map.put("ccc", 3);
    	map.put("ddd", 4);
    	map.put("eee", 5);
    	s.sellProducts(map);
    	s.sellProducts(map1);
    	try {
    	}catch(Exception e) {
    		s.sellProducts(null);
    	}
    }
    @Test(timeout = 4000)
    public void test5() {
    	RoomType ty=new RoomType();
    	ty.isRoomType("th");
    	OrderItem order3=new OrderItem("aaa",10,10);
    	OrderItem order1=new OrderItem("bbb",12,10);
    	OrderItem order2=new OrderItem("ccc",14,10);
    	OrderItem order4=new OrderItem(" ",14,10);
    	OrderItem order5=new OrderItem("ccc",14,10);
    	order1.PrintOrderItem();
    	order1.getProductName();
    	order1.getCount();
    	order1.setProductName("ddd");
    	order1.setCount(100);
    	List<OrderItem> items=new ArrayList();
    	items.add(order1);
    	items.add(order2);
    	items.add(order3);
    	items.add(order4);
    	items.add(order5);
    	Order o=new Order(items);
    	o.createOrder(items);
    	o.printOrderDetails();
    	o.printOrders();
    	o.searchMaxOrder();
    	o.getItems();
    }
    @Test(timeout = 4000)
    public void test6() {
    	Room room=new Room();
    	Room room1=new Room(122,RoomType.STANDARD,7,20.0);
    	Room room2=new Room(123,RoomType.STANDARD,7,20.0);
    	Room room3=new Room(124,RoomType.STANDARD,7,20.0);
    	Room room4=new Room(125,RoomType.STANDARD,7,20.0);
    	Room room5=new Room(126,RoomType.STANDARD,7,20.0);
        CheckInState c=new  CheckInState();
        try {
        	c.book(room);
        }catch(Exception e) {
        }
        Manager m=new Manager();
    	//m.checkIn(1, 124);
    	m.checkIn(4, 123);
    	try {
    		m.checkIn(7, 125);
    	}catch(Exception e) {
    		
    	}
    	try {
    		m.checkIn(10, 124);
    	}catch(Exception e) {
    		
    	}
    	m.checkIn(10, 126);
    	m.transferPrice(100.0);
    	m.transferPrice(0.0);
    	m.transferPrice(-0.0);
    	FreeTimeState f=new FreeTimeState();
    	try {
    		f.unsubscribe(room4);
    	}catch(Exception e) {
    	}
    	try {
    		f.checkIn(room1);
    	}catch(Exception e) {
    	}
    	try {
    		f.checkOut(room1);
    	}catch(Exception e) {
    	}
    	BookedState b=new BookedState();
    	try {
    		b.book(room2);
    	}catch(Exception e) {
    		
    	}
    	b.checkIn(room2);
    }
}

预赛经验:不要两个题目都等到最后10分钟再交,做一题交一题,因为后面的时候上交的人数密度很大,导致上交缓慢或者失败,还有就是尽量不要利用eclipse插件交,要用web IDE上交比较快,分数比较准确。
预赛之后发布成绩和能力图,什么是能力图?就是慕测平台会整体分析你的运行效率、代码覆盖、可维护性、Bug检测、编码效率。还有全国排名,我的预选赛全国排名为第17名。

省赛

省赛也是4个小时,真的是一场持久战了。做了两个小时交了一个题目我就溜出去上个洗手间,洗把脸,散散步,振奋一下精神继续回去做题。
一个题目是关于图的AStar,需要构建一个图。
另一个题目是三元树TernaryTree,构建三元树。

AstarTest.java
package net.mooctest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.junit.Test
import net.mooctest.Graph.CostPathPair;
import net.mooctest.Graph.CostVertexPair;
import net.mooctest.Graph.Edge;
import net.mooctest.Graph.TYPE;
import net.mooctest.Graph.Vertex;

public class AStarTest {
	
	@Test(timeout = 4000)
    public void testV() throws Throwable {
		Vertex v0=new Vertex(1);
		Vertex v1=new Vertex(1);
		Vertex v2=new Vertex(1);
		Vertex v3=new Vertex(1);
		Vertex v4=new Vertex(1);
		Vertex v5=null;
		Vertex v6=null;
		try {
			Edge<Integer> e7=new Edge<Integer>(9,v5,v1);
		}catch(NullPointerException e) {
			
		}
		Edge<Integer> e1=new Edge<Integer>(9,v1,v0);
		Edge<Integer> e2=new Edge<Integer>(3,v1,v2);
		Edge<Integer> e3=new Edge<Integer>(5,v2,v3);
		Edge<Integer> e4=new Edge<Integer>(1,v3,v4);
		Edge<Integer> e5=new Edge<Integer>(6,v0,v4);
		Edge<Integer> e6=new Edge<Integer>(2,v2,v0);
		e1.compareTo(e2);
		try {
			e2.compareTo(null);
		}catch(NullPointerException e) {
			
		}
		System.out.println(e2.compareTo(e2));
		assertEquals(1,e1.compareTo(e2));
		assertEquals(-1,e2.compareTo(e5));
		assertEquals(0,e2.compareTo(e2));
		assertEquals(true,e1.equals(e1));
		assertEquals(false,e1.equals(e6));
		assertEquals(false,e2.equals(e6));
		assertEquals(false,e2.equals(e5));
		assertEquals(false,e2.equals(v1));
		assertEquals(false,e2.equals(null));
		assertEquals(false,e5.equals(null));
		Edge ee1=new Edge(e1);
		ee1.setCost(1);
		System.out.println(ee1.getCost());
		assertEquals(1,ee1.getCost());
		System.out.println(e1.getFromVertex());
		Vertex vv1=e1.getToVertex();
		assertEquals(vv1,e1.getToVertex());
		Vertex vv2=e1.getFromVertex();
		assertEquals(vv2,e1.getFromVertex());
		e1.hashCode();
		System.out.println(e1.hashCode());
		assertEquals(268119,e1.hashCode());
		e1.toString();
		System.out.println(e1.toString());
		v1.addEdge(e2);
		v1.addEdge(e1);
		v2.addEdge(e3);
		v2.addEdge(e6);
		v3.addEdge(e4);
		v0.addEdge(e5);
		assertEquals(1,v1.compareTo(vv1));
		assertEquals(-1,v1.compareTo(v2));
		assertEquals(-1,v0.compareTo(v1));
		assertEquals(0,v1.compareTo(v1));
		System.out.println(v1.compareTo(vv1));
		v1.equals(vv1);
		System.out.println(v2.equals(v4));
		assertEquals(false,v1.equals(vv1));
		assertEquals(true,v1.equals(v1));
		assertEquals(true,v1.equals(vv2));
		assertEquals(false,v0.equals(v1));
		assertEquals(false,v2.equals(v1));
		assertEquals(false,v2.equals(v4));
		Edge e_1=v1.getEdge(v2);
		Edge e_2=v1.getEdge(v0);
		Edge e_3=v1.getEdge(v4);
		Edge e_4=v4.getEdge(v1);
		System.out.println(v1.getEdge(v2));
		assertEquals(null,v1.getEdge(v1));
		assertEquals(e_1,v1.getEdge(v2));
		assertEquals(e_2,v1.getEdge(v0));
		assertEquals(e_3,v1.getEdge(v4));
		assertEquals(e_4,v4.getEdge(v1));
		List list1 = new ArrayList();
		List list2 = new ArrayList();
		list1=v1.getEdges();
		List list00=v0.getEdges();
		List list01=v1.getEdges();
		List list02=v2.getEdges();
		List list03=v3.getEdges();
		List list04=v4.getEdges();
		List list05=null;
		CostPathPair cp0=new CostPathPair(10,list00);
		CostPathPair cp1=new CostPathPair(3,list01);
		CostPathPair cp2=new CostPathPair(2,list02);
		CostPathPair cp3=new CostPathPair(101,list03);
		CostPathPair cp4=new CostPathPair(109,list04);
		try {
			CostPathPair cp5=new CostPathPair(109,list05);
		}catch(NullPointerException e) {
			
		}
		cp1.getCost();
		assertEquals(3,cp1.getCost());
		cp1.setCost(2);
		assertEquals(2,cp1.getCost());
		assertEquals(false,cp1.equals(cp0));
		assertEquals(true,cp1.equals(cp1));
		assertEquals(false,cp1.equals(cp2));
		assertEquals(list1,v1.getEdges());
		System.out.println(v1.getWeight());
		assertEquals(1,v1.getValue());
		assertEquals(1,v0.getValue());
		assertEquals(0,v1.getWeight());
		cp1.toString();
		cp1.hashCode();
		assertEquals(1674,cp1.hashCode());
		v1.pathTo(v2);
		System.out.println(v1.pathTo(v2));
		assertEquals(true,v1.pathTo(v2));
		assertEquals(true,v1.pathTo(v0));
		assertEquals(false,v1.pathTo(v4));
		v0.setWeight(1);
		v1.setWeight(3);
		v2.setWeight(5);
		v3.setWeight(7);
		v4.setWeight(9);
		assertEquals(1,v0.getWeight());
		assertEquals(3,v1.getWeight());
		assertEquals(5,v2.getWeight());
		assertEquals(7,v3.getWeight());
		assertEquals(9,v4.getWeight());
		v1.toString();
		AStar<Integer> aStar = new AStar<Integer>();
	    Graph g1=new Graph(TYPE.DIRECTED); 
	    Graph<Integer> gr=new Graph<Integer>();
	    Vertex v=new Vertex(1);
	    Graph<Integer> g2=new Graph(gr);
	    Graph gg=new Graph(g2);
	    gg.toString();
	    g1.toString();
	    gr.toString();
	    Collection<Vertex<Integer>> th1=new ArrayList<Vertex<Integer>>();
	    th1.add(v0);
	    th1.add(v1);
	    th1.add(v2);
	    th1.add(v3);
	    th1.add(v4);
	    Collection<Edge<Integer>> th1_1=new ArrayList<Edge<Integer>>();
	    th1_1.add(e1);
	    th1_1.add(e2);
	    th1_1.add(e3);
	    th1_1.add(e4);
	    th1_1.add(e5);
	    th1_1.add(e6);
	    Graph gtest1=new Graph(Graph.TYPE.DIRECTED,th1,th1_1);
	    Graph gtest2=new Graph(Graph.TYPE.UNDIRECTED,th1,th1_1);
	    try {
	    	
	    }catch(Exception e) {
	    	Graph gtest3=new Graph(Graph.TYPE.UNDIRECTED,null,null);
	    }
	    Graph gtest3=new Graph(th1,th1_1);
	    gtest1.getEdges();
	    gtest1.hashCode();
	    System.out.println(gtest1.hashCode());
	    assertEquals(0,gtest1.hashCode());
	    System.out.println(gtest1.equals(gtest3));
	    gtest1.equals(e3);
	    Graph gtest1_1=gtest1;
	    assertEquals(false,gtest1.equals(e3));
	    assertEquals(false,gtest1.equals(gtest2));
	    assertEquals(true,gtest1.equals(gtest1));
	    assertEquals(false,gtest1.equals(gtest3));
	    assertEquals(true,gtest1_1.equals(gtest1));
	    gtest1.equals(null);
	    gtest1.getType();
	    System.out.println(gtest1.getType());//DIRECTED
	    List list4=gtest1.getVertices();
	    list4.toString();
	    System.out.println(list4.toString());
	    
	}
            
    @Test
    public void testAStarDirected() {
       AStar<Integer> aStar = new AStar<Integer>();
       Graph g1=new Graph(TYPE.DIRECTED); 
       Graph<Integer> gr=new Graph<Integer>();
       Vertex v=new Vertex(1);
       Graph<Integer> g2=new Graph(gr);
       aStar.aStar(g1, v, null);
       aStar.aStar(g2, v, null);
      // aStar.aStar(g2, null, null);
       aStar.distanceBetween(v, v);
       aStar.distanceBetween(v, null);
    }
    
    
    @Test(timeout = 4000)
    public void test1() throws Throwable {
    	Vertex<Integer> v0=new Vertex<Integer>(1,2);
		Vertex<Integer> v1=new Vertex<Integer>(v0);
		Vertex<Integer> v2=new Vertex<Integer>(v1);
		Vertex<Integer> v3=new Vertex<Integer>(v2);
		Vertex<Integer> v4=new Vertex<Integer>(v3); 
		Vertex <Integer>v5=null;
		CostVertexPair c0=new CostVertexPair(10,v0);
		CostVertexPair c1=new CostVertexPair(1,v1);
		CostVertexPair c2=new CostVertexPair(0,v2);
		CostVertexPair c3=new CostVertexPair(100,v3);
		CostVertexPair c4=new CostVertexPair(5,v4);
		try {
			CostVertexPair c5=new CostVertexPair(10,v5);
		}catch(NullPointerException e) {
			
		}
		System.out.println(c0.getCost());
		assertEquals(10,c0.getCost());
		c0.setCost(12);
		assertEquals(12,c0.getCost());
		assertEquals(true,c0.equals(c0));
		assertEquals(false,c0.equals(c1));
		assertEquals(false,c1.equals(c0));
		assertEquals(false,c2.equals(c3));
		assertEquals(false,c2.equals(v3));
		try {
			c1.compareTo(null);
		}catch(NullPointerException e) {
		}
		assertEquals(0,c2.compareTo(c2));
		assertEquals(-1,c2.compareTo(c1));
		assertEquals(-1,c2.compareTo(c4));
		assertEquals(-1,c2.compareTo(c3));
		assertEquals(1,c3.compareTo(c2));
		c1.toString();
		c2.toString();
	}
    @Test(timeout = 4000)
    public void test2() throws Throwable {
    }
    @Test(timeout = 4000)
    public void test3() throws Throwable {
    }
    @Test(timeout = 4000)
    public void test4() throws Throwable {
    	
    }

}

TernaryTreeTest.java
package net.mooctest;

import org.junit.Test;
import static org.junit.Assert.*;

import java.util.EmptyStackException;
import java.util.Iterator;
import java.util.NoSuchElementException;


public class TernaryTreeTest{

  @Test(timeout = 4000)
  public void test(){
	  TernaryTree<Integer> t_1 = new TernaryTree<Integer>();
      TernaryTree<Integer> t1 = new TernaryTree<Integer>(10);
      TernaryTree<Integer> t2 = new TernaryTree<Integer>(5);
      TernaryTree<Integer> t3 = new TernaryTree<Integer>(2);
      TernaryTree<Integer> t4 = new TernaryTree<Integer>(15);
      TernaryTree<Integer> t5 = new TernaryTree<Integer>(20);
      TernaryTree<Integer> t6 = new TernaryTree<Integer>(18);
      TernaryTree<Integer> t7 = new TernaryTree<Integer>(30);
      TernaryTree<Integer> t8 = new TernaryTree<Integer>(40);
      TernaryTree<Integer> t9 = new TernaryTree<Integer>(35);
      TernaryTree<Integer> t10 = new TernaryTree<Integer>(38);
      TernaryTree<Integer> t11 = new TernaryTree<Integer>(32);
      TernaryTree<Integer> t12 = new TernaryTree<Integer>(30);
      TernaryTree<Integer> t13=null;
      TernaryTree<Integer> t0 = new TernaryTree<Integer>(1,t1,t2,t3);
      t0.setTree(11);
      t0.getRootData();
      System.out.println(t0.getRootData());
      assertEquals((Integer)11,t0.getRootData());
      t0.setTree(8,t1,t2,t3);
      t1.setTree(9,t4,t5,t6);
      t5.setTree(10,t7,t8,t9);
      t2.setTree(6, t13, t13, t13);
      try {
    	  t_1.getRootData();
      }catch(EmptyTreeException e) {
    	  
      }
      t0.setRootData(8);
      assertEquals((Integer)8,t0.getRootData());
      System.out.println(t0.getHeight());
      assertEquals(1,t0.getHeight());
      assertEquals(1, t0.getRootNode().getHeight());
      t0.getRootNode();
      assertEquals(1, t0.getNumberOfNodes());
      t0.getNumberOfNodes();
      t1.iterativePreorderTraverse();
      t_1.iterativePreorderTraverse();
      
      Iterator<Integer> pr1=t1.getPreorderIterator();
      Iterator<Integer> po1=t1.getPostorderIterator();
      Iterator<Integer> pr2=t3.getPreorderIterator();
      Iterator<Integer> po2=t3.getPostorderIterator();
      Iterator<Integer> pr3=t5.getPreorderIterator();
      Iterator<Integer> po3=t5.getPostorderIterator();
      
      Iterator<Integer> lo1=t0.getLevelOrderIterator();
      Iterator<Integer> lo2=t1.getLevelOrderIterator();
      Iterator<Integer> lo3=t2.getLevelOrderIterator();
      Iterator<Integer> lo4=t5.getLevelOrderIterator();
      Iterator<Integer> lo5=t9.getLevelOrderIterator();
      Iterator<Integer> lo6=t2.getLevelOrderIterator();
      Iterator<Integer> lo7=t10.getLevelOrderIterator();
      Iterator<Integer> lo8=t8.getLevelOrderIterator();
      Iterator<Integer> lo9=t7.getLevelOrderIterator();
      Iterator<Integer> po4=t2.getPostorderIterator();
      Iterator<Integer> po5=t3.getPostorderIterator();
      Iterator<Integer> po6=t7.getPostorderIterator();
      Iterator<Integer> po7=t4.getPostorderIterator();
      Iterator<Integer> po8=t9.getPostorderIterator();
      Iterator<Integer> po9=t10.getPostorderIterator();
      System.out.println("aaaaaaaaa");
      assertEquals((Integer)6,po4.next());
      assertEquals((Integer)15,po1.next());
      assertEquals((Integer)30,po3.next());
      assertEquals((Integer)38,po9.next());
  
      try {
    	  lo5.next();
      }catch(NoSuchElementException e) {
    	  
      }
      
      
      System.out.println(lo5.hasNext());
      assertEquals(false,lo5.hasNext());
      assertEquals(true,lo6.hasNext());
      assertEquals(true,lo1.hasNext());
      assertEquals(true,lo2.hasNext());
      assertEquals(true,lo3.hasNext());
      assertEquals(true,lo4.hasNext());
      assertEquals(true,pr1.hasNext());
      assertEquals(false,po2.hasNext());
      System.out.println("thaoahoah");
     
      assertEquals((Integer)8,lo1.next());
      assertEquals((Integer)9,lo2.next());
      assertEquals((Integer)6,lo3.next());
      assertEquals((Integer)10,lo4.next());
      try {
    	  lo4.remove();
      }catch(UnsupportedOperationException e) {
    	  
      }
     
      try {
    	  pr2.next();
      }catch(NoSuchElementException e) {
    	  
      }
      
      System.out.println(pr3.next());
      System.out.println(po3.next());
      assertEquals((Integer)9,pr1.next());
      assertEquals((Integer)30,pr3.next());
      try {
    	  pr2.remove(); 
      }catch(UnsupportedOperationException e) {
    	  
      }
      LinkedQueue<Integer> link0=new LinkedQueue<Integer>();
      link0.enqueue(10);
      link0.getFront();
      assertEquals((Integer)10,link0.getFront());
      System.out.println(link0.dequeue());
      try {
    	  assertEquals((Integer)10,link0.dequeue());
      }catch(EmptyQueueException e) {
      }
      assertEquals(true,link0.isEmpty());
      link0.isEmpty();
      link0.clear();
      
  }
  @Test(timeout = 4000)
  public void test1(){
	  TernaryNode<Integer> t_1 = new TernaryNode<Integer>();
	  TernaryNode<Integer> t1 = new TernaryNode<Integer>(10);
	  TernaryNode<Integer> t2 = new TernaryNode<Integer>(5);
	  TernaryNode<Integer> t3 = new TernaryNode<Integer>(2);
	  TernaryNode<Integer> t4 = new TernaryNode<Integer>(15);
	  TernaryNode<Integer> t5 = new TernaryNode<Integer>(20);
	  TernaryNode<Integer> t6 = new TernaryNode<Integer>(18);
	  TernaryNode<Integer> t7 = new TernaryNode<Integer>(30);
	  TernaryNode<Integer> t8 = new TernaryNode<Integer>(40);
	  TernaryNode<Integer> t10 = new TernaryNode<Integer>(38);
	  TernaryNode<Integer> t11 = new TernaryNode<Integer>(32);
	  TernaryNode<Integer> t12 = new TernaryNode<Integer>(30);
	  TernaryNode<Integer> t13=null;
	  TernaryNode<Integer> t0 = new TernaryNode<Integer>(1,t1,t2,t3);
      t0.setLeftChild(t1);
      t0.setMiddleChild(t2);
      t0.setRightChild(t3);
      t1.setLeftChild(t4);
      t2.setMiddleChild(t5);
      t3.setMiddleChild(t6);
      t5.setLeftChild(t7);
      t5.setMiddleChild(t8);
      t5.setRightChild(t10);
	  
      System.out.println(t3.hasLeftChild());
      assertEquals(false,t3.hasLeftChild());
      assertEquals(true,t1.hasLeftChild());
      assertEquals(true,t5.hasLeftChild());
      assertEquals(true,t3.hasMiddleChild());
      assertEquals(false,t1.hasMiddleChild());
      assertEquals(true,t5.hasMiddleChild());
      assertEquals(false,t3.hasRightChild());
      assertEquals(false,t1.hasRightChild());
      assertEquals(true,t5.hasRightChild());
      assertEquals(true,t4.isLeaf());
      assertEquals(false,t1.isLeaf());
      assertEquals(false,t5.isLeaf());
      assertEquals(true,t7.isLeaf());
      assertEquals(false,t0.isLeaf());
      System.out.println("-------");
     
      assertEquals(10,t0.getNumberOfNodes());
      assertEquals(2,t1.getNumberOfNodes());
      assertEquals(5,t2.getNumberOfNodes());
      assertEquals(2,t3.getNumberOfNodes());
      assertEquals(1,t4.getNumberOfNodes());
      assertEquals(4,t5.getNumberOfNodes());
      assertEquals(1,t6.getNumberOfNodes());
      assertEquals(1,t7.getNumberOfNodes());
      assertEquals(1,t8.getNumberOfNodes());
      assertEquals(1,t10.getNumberOfNodes());
      
      TernaryNode<Integer> tt0=t0.copy();
      TernaryNode<Integer> tt1=t1.copy();
      TernaryNode<Integer> tt2=t2.copy();
      TernaryNode<Integer> tt3=t3.copy();
      tt0.isLeaf();
  }
  @Test(timeout = 4000)
  public void test2(){
	  LinkedStack<Integer> link0=new LinkedStack<Integer>();
      try {
    	  assertEquals((Integer)10,link0.peek());
      }catch(EmptyStackException e) {
      }
      assertEquals(true,link0.isEmpty());
      link0.isEmpty();
      link0.clear();
  }
}


做的过程中截的图

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
上午比赛结束,累得我下午一直在躺,等到下午4点多,院长老师给我发信息,一张截图,看到了我的名字,然后什么也没说,我也不知道啥意思,我就问:老师我这成绩能进省三吗?他说成绩还没完全出来,也不知道。然后我说好的。之后到了晚上老师发来了一个开发者测试省赛成绩排名链接,我看了一下我竟然是第一(校内)。我都蒙皮了,之后上课老师说很遗憾我们可能没有能进决赛的了,最高的就是全省二等奖,当时是全省一等奖3人才能进决赛,之后如果排名靠前可以考虑进入决赛,老师说他要为我们学校争取争取。之后的决赛入围名单上就有了我,代表我们学校唯一一个进入开发者测试决赛的去广州参加决赛。
我的省赛成绩排名全国70,当时好像是全国前80都能进决赛。
下面是我的省赛能力图:

决赛

https://blog.csdn.net/weixin_42139772/article/details/112783946.

  • 11
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
网易云音乐是国内知名的在线音乐平台,为广大音乐爱好者提供了丰富的音乐资源和多样的功能。软件测试是确保软件质量和稳定性的重要环节,而全国大学生软件测试大赛中的题目之一就是网易云音乐web功能测试。 首先,我们需要明确测试的目标和范围。在网易云音乐web功能测试中,可以考虑以下几个方面:用户注册登录功能、音乐播放功能、歌单管理功能、搜索功能、个人信息设置功能等。 对于用户注册登录功能,我们可以测试注册新用户的过程和登录已有用户的过程。测试项包括输入合法的、非法的用户信息是否能正确验证,以及登录后个人信息是否正确显示等。 音乐播放功能是网易云音乐的核心功能之一。我们可以测试播放音乐时是否流畅,能否正常切换音乐,是否支持多种格式的音乐文件,是否能够实现音量调节、音乐暂停和继续播放等。 歌单管理功能是用户可以自己创建歌单、添加和移除歌曲的功能。我们可以测试歌单的创建过程是否顺利,添加和删除歌曲是否成功,以及歌单的信息是否正确显示等。 对于搜索功能,我们可以测试用户输入关键词后,能否正确显示相关的音乐、歌手或专辑信息。还可以测试搜索功能的响应速度和搜索结果的准确性。 个人信息设置功能包括用户个人资料的修改、密码的修改和绑定第三方账号等。我们可以测试用户修改个人资料后,是否能及时更新显示,密码修改后是否可以正常登录,以及与第三方账号的绑定是否成功等。 综上所述,全国大学生软件测试大赛中的网易云音乐web功能测试题目涉及到了多个方面的功能测试。通过逐一测试这些功能,可以确保网易云音乐的用户体验和功能完整性,为用户提供更好的音乐服务。同时,这样的测试也是对测试人员技术能力的考验和提升。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值