Home | History | Annotate | Download | only in collect
      1 /*
      2  * Copyright (C) 2011 The Guava Authors
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
      5  * in compliance with the License. You may obtain a copy of the License at
      6  *
      7  * http://www.apache.org/licenses/LICENSE-2.0
      8  *
      9  * Unless required by applicable law or agreed to in writing, software distributed under the License
     10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
     11  * or implied. See the License for the specific language governing permissions and limitations under
     12  * the License.
     13  */
     14 
     15 package com.google.common.collect;
     16 
     17 import static com.google.common.collect.BstTesting.countAggregate;
     18 
     19 import com.google.common.annotations.GwtCompatible;
     20 import com.google.common.collect.BstTesting.SimpleNode;
     21 
     22 import junit.framework.Test;
     23 import junit.framework.TestCase;
     24 import junit.framework.TestSuite;
     25 
     26 /**
     27  * Tests for the policies exported by {@link BstCountBasedBalancePolicies}
     28  *
     29  * @author Louis Wasserman
     30  */
     31 @GwtCompatible
     32 public class BstCountBasedBalancePoliciesTest extends TestCase {
     33   public static class NoRebalanceTest extends AbstractBstBalancePolicyTest {
     34     @Override
     35     protected BstBalancePolicy<SimpleNode> getBalancePolicy() {
     36       return BstCountBasedBalancePolicies.noRebalancePolicy(countAggregate);
     37     }
     38   }
     39 
     40   public static class SingleRebalanceTest extends AbstractBstBalancePolicyTest {
     41     @Override
     42     protected BstBalancePolicy<SimpleNode> getBalancePolicy() {
     43       return BstCountBasedBalancePolicies.<Character, SimpleNode>singleRebalancePolicy(
     44           countAggregate);
     45     }
     46   }
     47 
     48   public static class FullRebalanceTest extends AbstractBstBalancePolicyTest {
     49     @Override
     50     protected BstBalancePolicy<SimpleNode> getBalancePolicy() {
     51       return BstCountBasedBalancePolicies.<Character, SimpleNode>fullRebalancePolicy(
     52           countAggregate);
     53     }
     54   }
     55 
     56   public static Test suite() {
     57     TestSuite suite = new TestSuite();
     58     suite.addTestSuite(NoRebalanceTest.class);
     59     suite.addTestSuite(SingleRebalanceTest.class);
     60     suite.addTestSuite(FullRebalanceTest.class);
     61     return suite;
     62   }
     63 }
     64