blob: 86add9376b53f524566e7cc982dc3d736905e4c0 [file] [log] [blame]
Simon Hunt933b1a82015-05-04 19:07:24 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
17
18package org.onosproject.ui.table;
19
20import org.junit.Test;
21
22import static org.junit.Assert.assertTrue;
23
24/**
25 * Unit tests for {@link DefaultCellComparator}.
26 */
27public class DefaultCellComparatorTest {
28
29 private static class TestClass {
30 @Override
31 public String toString() {
32 return SOME;
33 }
34 }
35
36 private static final String SOME = "SoMeStRiNg";
37 private static final String OTHER = "OtherSTRING";
38 private static final int NUMBER = 42;
39 private static final TestClass OBJECT = new TestClass();
40
41 private CellComparator cmp = new DefaultCellComparator();
42
43 @Test
44 public void sameString() {
45 assertTrue("same string", cmp.compare(SOME, SOME) == 0);
46 }
47
48 @Test
49 public void someVsOther() {
50 assertTrue("some vs other", cmp.compare(SOME, OTHER) > 0);
51 }
52
53 @Test
54 public void otherVsSome() {
55 assertTrue("other vs some", cmp.compare(OTHER, SOME) < 0);
56 }
57
58 @Test
59 public void someVsObject() {
60 assertTrue("some vs object", cmp.compare(SOME, OBJECT) == 0);
61 }
62
63 @Test
64 public void otherVsObject() {
65 assertTrue("other vs object", cmp.compare(OTHER, OBJECT) < 0);
66 }
67
68 @Test
69 public void otherVsNumber() {
70 assertTrue("other vs 42", cmp.compare(OTHER, NUMBER) > 0);
71 }
72
73 @Test
74 public void someVsNull() {
75 assertTrue("some vs null", cmp.compare(SOME, null) > 0);
76 }
77
78 @Test
79 public void nullVsSome() {
80 assertTrue("null vs some", cmp.compare(null, SOME) < 0);
81 }
82
83}