/tst/org/diffkit/diff/engine/tst/TestTableModel.groovy

http://diffkit.googlecode.com/ · Groovy · 45 lines · 18 code · 9 blank · 18 comment · 2 complexity · 48c2b66e0f0437afebc1022a29b51f65 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.diff.engine.tst
  17. import org.diffkit.diff.engine.DKColumnModel;
  18. import org.diffkit.diff.engine.DKTableModel
  19. import groovy.util.GroovyTestCase;
  20. /**
  21. * @author jpanico
  22. */
  23. public class TestTableModel extends GroovyTestCase {
  24. public void testKeyValues(){
  25. DKColumnModel column1_1 = [0, 'column1_1', DKColumnModel.Type.STRING]
  26. DKColumnModel column1_2 = [1, 'column1_2', DKColumnModel.Type.STRING]
  27. DKColumnModel column1_3 = [2, 'column1_3', DKColumnModel.Type.INTEGER]
  28. DKColumnModel[] columns = [column1_1, column1_2, column1_3]
  29. int[] key = [0,2]
  30. DKTableModel lhsTable = ["lhs_table",columns, key]
  31. println "column1_1->$column1_1"
  32. println "lhsTable->$lhsTable"
  33. assert lhsTable.getKeyValues((Object[])['zzzz', 'aaaa', 1]) == ['zzzz',1]
  34. assert lhsTable.getKeyValues((Object[])['zzzz', 'zzzz', 2]) == ['zzzz',2]
  35. }
  36. }