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