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 org.junit.After;
27 import org.junit.AfterClass;
28 import org.junit.Before;
29 import org.junit.BeforeClass;
30 import org.junit.Test;
31 import static org.junit.Assert.*;
35 * @author TJ <hacker@iam.tj>
37 public class WSYD_Member_Comparator_UserNameTest {
38 WSYD_Member_Comparator_UserName instance;
41 public WSYD_Member_Comparator_UserNameTest() {
45 public static void setUpClass() {
49 public static void tearDownClass() {
54 instance = new WSYD_Member_Comparator_UserName();
55 member = new WSYD_Member();
56 member._userName = "Eddie";
60 public void tearDown() {
64 * Test of compare method, of class WSYD_Member_Comparator_UserName.
67 public void testCompare() {
68 System.out.println(java.text.MessageFormat.format("{0}.compare(value, value)", instance.getClass().getName()));
69 WSYD_Member l = new WSYD_Member();
70 WSYD_Member m = new WSYD_Member();
71 WSYD_Member n = new WSYD_Member();
72 WSYD_Member o = new WSYD_Member();
73 l._userName = "Below";
74 m._userName = "Eddie";
75 n._userName = "Higher";
77 assertEquals( 3, instance.compare(member, l));
78 assertEquals( 0, instance.compare(member, m));
79 assertEquals(-3, instance.compare(member, n));
80 assertEquals(-1, instance.compare(member, o));
83 @Test (expected=NullPointerException.class)
84 public void testNPEuser1() {
85 System.out.println(java.text.MessageFormat.format("{0}.compare(null, value)", instance.getClass().getName()));
86 instance.compare(member, null);
89 @Test (expected=NullPointerException.class)
90 public void testNPEuser2() {
91 System.out.println(java.text.MessageFormat.format("{0}.compare(value, null)", instance.getClass().getName()));
92 instance.compare(null, member);
95 @Test (expected=NullPointerException.class)
96 public void testNPEboth() {
97 System.out.println(java.text.MessageFormat.format("{0}.compare(null,null)", instance.getClass().getName()));
98 instance.compare(null, null);