/tst/org/diffkit/common/tst/TestElementComparator.groovy

http://diffkit.googlecode.com/ · Groovy · 42 lines · 15 code · 9 blank · 18 comment · 3 complexity · 9a7af352d74b7ff58c318a15eda39efd MD5 · raw file

  1. /**
  2. * Copyright 2010-2011 Joseph Panico
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.diffkit.common.tst
  17. import org.diffkit.common.DKComparableComparator;
  18. import org.diffkit.common.DKElementComparator;
  19. import groovy.util.GroovyTestCase;
  20. /**
  21. * @author jpanico
  22. */
  23. public class TestElementComparatorentComparator extends GroovyTestCase {
  24. public void testCompare(){
  25. Object[] lhs = ['value1', 'value2', 3, 'value4', 2]
  26. Object[] rhs = ['value0', 'value1', 3, 'value4', 3]
  27. assert new DKElementComparator(0,0, DKComparableComparator.instance).compare(lhs, rhs) > 0
  28. assert new DKElementComparator(0,1, DKComparableComparator.instance).compare(lhs, rhs) == 0
  29. assert new DKElementComparator(2,2, DKComparableComparator.instance).compare(lhs, rhs) == 0
  30. assert new DKElementComparator(3,3, DKComparableComparator.instance).compare(lhs, rhs) == 0
  31. assert new DKElementComparator(4,4, DKComparableComparator.instance).compare(lhs, rhs) < 0
  32. }
  33. }