blob: 26fc7a1d173324ca417f4d837024049bc73e36c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package ca.mokhan.test;
import Q1.*;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class ReversedSentenceTest extends TestCase {
private ReversedSentence subject;
public ReversedSentenceTest(String testName) {
super(testName);
this.subject = new ReversedSentence();
}
public static Test suite() {
return new TestSuite(ReversedSentenceTest.class);
}
public void testTruthy() {
assertEquals(true, true);
}
public void testReverseByCharacter() {
assertEquals(
"bmal elttil a dah yram", ReversedSentence.reverseByCharacter("mary had a little lamb"));
}
public void testReverseByWord() {
assertEquals(
"lamb little a had mary", ReversedSentence.reverseByWord("mary had a little lamb"));
}
public void testChange5thPosition() {
assertEquals(
"mary zad azlittze lazb", ReversedSentence.change5thPosition("mary had a little lamb"));
}
public void testPrintChar2DArray() {
char[][] matrix = new char[3][80];
String sentence = "mary had a little lamb";
matrix[0] = ReversedSentence.reverseByCharacter(sentence).toCharArray();
matrix[1] = ReversedSentence.reverseByWord(sentence).toCharArray();
matrix[2] = ReversedSentence.change5thPosition(sentence).toCharArray();
String expected =
String.join(
System.lineSeparator(),
new String(matrix[0]),
new String(matrix[1]),
new String(matrix[2]));
assertEquals(expected, ReversedSentence.printChar2DArray(matrix));
}
}
|