Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b4db0f49cc
1 changed files with 51 additions and 46 deletions
|
@ -1,9 +1,14 @@
|
||||||
|
/**
|
||||||
|
* @(#) DictionaryEntryTest.java 0,1 2020/05/01
|
||||||
|
* <p>
|
||||||
|
* Copyright (c) 2020 Aberystwyth University.
|
||||||
|
* All rights reserved.
|
||||||
|
*/
|
||||||
package uk.ac.aber.cs221.group20.test;
|
package uk.ac.aber.cs221.group20.test;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import uk.ac.aber.cs221.group20.json.DictionaryEntry;
|
import uk.ac.aber.cs221.group20.json.DictionaryEntry;
|
||||||
import uk.ac.aber.cs221.group20.json.JsonProcessing;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -11,59 +16,59 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A test class for various tests regarding DictionaryEntry.
|
* A test class for various tests regarding DictionaryEntry.
|
||||||
* @Author Kab74
|
* @author Kain Bryan-Jones [kab74]
|
||||||
*/
|
*/
|
||||||
class DictionaryEntryTest {
|
class DictionaryEntryTest {
|
||||||
|
|
||||||
LinkedList<DictionaryEntry> testList;
|
LinkedList<DictionaryEntry> testList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether the default constructor sets isPracticeWord to false upon declaration of a new DictionaryEntry.
|
* Tests whether the default constructor sets isPracticeWord to false upon declaration of a new DictionaryEntry.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void testPracticeWordFalse(){
|
void testPracticeWordFalse(){
|
||||||
DictionaryEntry testDefaultConstructor = new DictionaryEntry();
|
DictionaryEntry testDefaultConstructor = new DictionaryEntry();
|
||||||
assertFalse(testDefaultConstructor.isPracticeWord());
|
assertFalse(testDefaultConstructor.isPracticeWord());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether the setters and getters of the DictionaryEntry class work as intended.
|
* Tests whether the setters and getters of the DictionaryEntry class work as intended.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void testAllSettersAndGetters() {
|
void testAllSettersAndGetters() {
|
||||||
String english = "abbey";
|
String english = "abbey";
|
||||||
String welsh = "abaty";
|
String welsh = "abaty";
|
||||||
wordTypeEnum wordType = wordTypeEnum.nm;
|
DictionaryEntry.wordTypeEnum wordType = DictionaryEntry.wordTypeEnum.nm;
|
||||||
|
|
||||||
DictionaryEntry testSettersAndGetters = new DictionaryEntry();
|
DictionaryEntry testSettersAndGetters = new DictionaryEntry();
|
||||||
testSettersAndGetters.setEnglish(english);
|
testSettersAndGetters.setEnglish(english);
|
||||||
testSettersAndGetters.setWelsh(welsh);
|
testSettersAndGetters.setWelsh(welsh);
|
||||||
testSettersAndGetters.setWordType(wordType);
|
testSettersAndGetters.setWordType(wordType);
|
||||||
assertTrue(testSettersAndGetters.getEnglish().equals(english) &&
|
assertTrue(testSettersAndGetters.getEnglish().equals(english) &&
|
||||||
testSettersAndGetters.getWelsh().equals(welsh) &&
|
testSettersAndGetters.getWelsh().equals(welsh) &&
|
||||||
testSettersAndGetters.getWordType().equals(wordType));
|
testSettersAndGetters.getWordType().equals(wordType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A true-positive test for the equals method in DictionaryEntry.
|
* A true-positive test for the equals method in DictionaryEntry.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEqualsTruePossitive() {
|
public void testEqualsTruePossitive() {
|
||||||
String english = "abbey";
|
String english = "abbey";
|
||||||
String welsh = "abaty";
|
String welsh = "abaty";
|
||||||
wordTypeEnum wordType = wordTypeEnum.nm;
|
DictionaryEntry.wordTypeEnum wordType = DictionaryEntry.wordTypeEnum.nm;
|
||||||
testList = new LinkedList<>(Arrays.asList(new DictionaryEntry(english,welsh,wordType),new DictionaryEntry(english,welsh,wordType)));
|
testList = new LinkedList<>(Arrays.asList(new DictionaryEntry(english,welsh,wordType),new DictionaryEntry(english,welsh,wordType)));
|
||||||
assertTrue(testList.get(0).equals(testList.get(1)));
|
assertTrue(testList.get(0).equals(testList.get(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A true-negative test for the equals method in DictionaryEntry.
|
* A true-negative test for the equals method in DictionaryEntry.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEqualsTrueNegative(){
|
public void testEqualsTrueNegative(){
|
||||||
testList = new LinkedList<>(Arrays.asList(new DictionaryEntry("abbey","abaty", wordTypeEnum.nm),new DictionaryEntry("above","dramor",wordTypeEnum.other)));
|
testList = new LinkedList<>(Arrays.asList(new DictionaryEntry("abbey","abaty", DictionaryEntry.wordTypeEnum.nm),new DictionaryEntry("above","dramor", DictionaryEntry.wordTypeEnum.other)));
|
||||||
assertFalse(testList.get(0).equals(testList.get(1)));
|
assertFalse(testList.get(0).equals(testList.get(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue