4 * Copyright 2015 Eddie Berrisford-Lynch <n0521366@ntu.ac.uk>.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 package uk.ac.ntu.n0521366.wsyd.libs;
26 import java.text.MessageFormat;
27 import org.junit.After;
28 import org.junit.AfterClass;
29 import org.junit.Before;
30 import org.junit.BeforeClass;
31 import org.junit.Test;
32 import static org.junit.Assert.*;
36 * @author TJ <hacker@iam.tj>
38 public class WSYD_Member_Comparator_UserIDTest {
39 WSYD_Member_Comparator_UserID instance;
42 public WSYD_Member_Comparator_UserIDTest() {
46 public static void setUpClass() {
50 public static void tearDownClass() {
55 instance = new WSYD_Member_Comparator_UserID();
60 public void tearDown() {
64 * Test of compare method, of class WSYD_Member_Comparator_UserID.
67 public void testCompare() {
68 System.out.println(MessageFormat.format("{0}.compare(value, value)", instance.getClass().getName()));
69 assertEquals(0, instance.compare(user1, new Long(42)));
70 assertEquals(-1, instance.compare(user1, new Long(43)));
71 assertEquals(1, instance.compare(user1, new Long(41)));
75 @Test (expected=NullPointerException.class)
76 public void testNPEuser1() {
77 System.out.println(MessageFormat.format("{0}.compare(null, value)", instance.getClass().getName()));
78 instance.compare(user1, null);
81 @Test (expected=NullPointerException.class)
82 public void testNPEuser2() {
83 System.out.println(MessageFormat.format("{0}.compare(value, null)", instance.getClass().getName()));
84 instance.compare(null, user1);
87 @Test (expected=NullPointerException.class)
88 public void testNPEboth() {
89 System.out.println(MessageFormat.format("{0}.compare(null,null)", instance.getClass().getName()));
90 instance.compare(null, null);