Commit 0b4d77e4 authored by Dr. Martin Goik's avatar Dr. Martin Goik

Decomposing test classes

parent a6fff326
package de.hdm_stuttgart.mi.sd1.test; package de.hdm_stuttgart.mi.sd1.test;
import de.hdm_stuttgart.mi.exam.unitmarking.RunTests; import de.hdm_stuttgart.mi.exam.unitmarking.RunTests;
import de.hdm_stuttgart.mi.sd1.test.task1.Test_HelperArray; import de.hdm_stuttgart.mi.sd1.test.task1.*;
import de.hdm_stuttgart.mi.sd1.test.task1.Test_Helper;
import de.hdm_stuttgart.mi.sd1.test.task2.Test_ChangeAmount; import de.hdm_stuttgart.mi.sd1.test.task2.Test_ChangeAmount;
public class ShowReachedPoints { public class ShowReachedPoints {
...@@ -14,11 +13,17 @@ public class ShowReachedPoints { ...@@ -14,11 +13,17 @@ public class ShowReachedPoints {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
RunTests.exec( RunTests.exec(
"Aufgabe 1" "Task 1"
, Test_Helper.class , Test_10_Helper_isAscending.class
, Test_HelperArray.class , Test_20_Helper_checkTitle.class
); , Test_30_Helper_isVowel.class
, Test_40_Helper_getNumberOfVowels.class
, Test_50_Helper_renameFileBasename.class
RunTests.exec("Aufgabe 2", Test_ChangeAmount.class); , Test_110_HelperArray_getAlphabeticalFollowers.class
, Test_120_HelperArray_getLeaders.class
);
RunTests.exec("Task 2", Test_ChangeAmount.class);
} }
} }
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test.task1;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
import de.hdm_stuttgart.mi.exam.unitmarking.Marking;
import de.hdm_stuttgart.mi.sd1.task1.Helper;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Test_10_Helper_isAscending extends ExaminationTestDefaults {
/* Section: isAscending */
@Test @Marking(points = 3) public void test_010_isAscending_positive() {
Assert.assertTrue(Helper.isAscending(1, 2, 3));
Assert.assertFalse("Second value not greater than first", Helper.isAscending(1, 1, 3));
Assert.assertFalse("All values are strictly descending", Helper.isAscending(3, 2, 1));
}
@Test @Marking(points = 3) public void test_020_isAscending_negative() {
Assert.assertTrue(Helper.isAscending(-41, -20, 30));
Assert.assertFalse("Second value not greater than first", Helper.isAscending(-50, -50, 3));
}
}
\ No newline at end of file
...@@ -13,7 +13,7 @@ import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getAlphabeticalFollowers ...@@ -13,7 +13,7 @@ import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getAlphabeticalFollowers
import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getLeaders; import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getLeaders;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Test_HelperArray extends ExaminationTestDefaults { public class Test_110_HelperArray_getAlphabeticalFollowers extends ExaminationTestDefaults {
private static void assertArrayEmpty(final String[] values){ private static void assertArrayEmpty(final String[] values){
Assert.assertArrayEquals( Assert.assertArrayEquals(
...@@ -21,8 +21,6 @@ public class Test_HelperArray extends ExaminationTestDefaults { ...@@ -21,8 +21,6 @@ public class Test_HelperArray extends ExaminationTestDefaults {
values); values);
} }
/* Section: getAlphabeticalFollowers */
@Test @Marking(points = 4) public void test_400_testSpecialCases() { @Test @Marking(points = 4) public void test_400_testSpecialCases() {
assertArrayEmpty(getAlphabeticalFollowers(null, null)); assertArrayEmpty(getAlphabeticalFollowers(null, null));
...@@ -88,28 +86,4 @@ public class Test_HelperArray extends ExaminationTestDefaults { ...@@ -88,28 +86,4 @@ public class Test_HelperArray extends ExaminationTestDefaults {
assertFilter(values, values, ""); assertFilter(values, values, "");
assertFilter(values, values, "alph"); assertFilter(values, values, "alph");
} }
/* Section: getLeaders */
@Test public void test_600_singleLeader() {
Assert.assertArrayEquals(new int[]{-3}, getLeaders(new int[]{-3}));
Assert.assertArrayEquals(new int[]{1, 0}, getLeaders(new int[]{1, 0}));
Assert.assertArrayEquals(new int[]{1}, getLeaders(new int[]{0, 1}));
}
@Test public void test_620_edgeDuplicate() {
Assert.assertArrayEquals(new int[]{3, 3}, getLeaders(new int[]{1, 3, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{4, 3}, getLeaders(new int[]{1, 4, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{3}, getLeaders(new int[]{1, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{3, 3}, getLeaders(new int[]{3, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{6, 3}, getLeaders(new int[]{6, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{17, 5, 2}, getLeaders(new int[]{16, 17, 4, 3, 5, 2}));
}
@Test public void test_640_all() {
Assert.assertArrayEquals(new int[]{5,4,3,2,1,0}, getLeaders(new int[]{5,4,3,2,1,0}));
Assert.assertArrayEquals(new int[]{4,4,4,4,4,4,4}, getLeaders(new int[]{4,4,4,4,4,4,4}));
}
} }
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test.task1;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
import de.hdm_stuttgart.mi.exam.unitmarking.Marking;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.util.Arrays;
import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getAlphabeticalFollowers;
import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getLeaders;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Test_120_HelperArray_getLeaders extends ExaminationTestDefaults {
@Test public void test_600_singleLeader() {
Assert.assertArrayEquals(new int[]{-3}, getLeaders(new int[]{-3}));
Assert.assertArrayEquals(new int[]{1, 0}, getLeaders(new int[]{1, 0}));
Assert.assertArrayEquals(new int[]{1}, getLeaders(new int[]{0, 1}));
}
@Test public void test_620_edgeDuplicate() {
Assert.assertArrayEquals(new int[]{3, 3}, getLeaders(new int[]{1, 3, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{4, 3}, getLeaders(new int[]{1, 4, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{3}, getLeaders(new int[]{1, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{3, 3}, getLeaders(new int[]{3, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{6, 3}, getLeaders(new int[]{6, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{17, 5, 2}, getLeaders(new int[]{16, 17, 4, 3, 5, 2}));
}
@Test public void test_640_all() {
Assert.assertArrayEquals(new int[]{5,4,3,2,1,0}, getLeaders(new int[]{5,4,3,2,1,0}));
Assert.assertArrayEquals(new int[]{4,4,4,4,4,4,4}, getLeaders(new int[]{4,4,4,4,4,4,4}));
}
}
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test.task1; package de.hdm_stuttgart.mi.sd1.test.task1;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
import de.hdm_stuttgart.mi.exam.unitmarking.Marking; import de.hdm_stuttgart.mi.exam.unitmarking.Marking;
import de.hdm_stuttgart.mi.sd1.task1.Helper; import de.hdm_stuttgart.mi.sd1.task1.Helper;
import org.junit.Assert; import org.junit.Assert;
...@@ -7,24 +8,8 @@ import org.junit.FixMethodOrder; ...@@ -7,24 +8,8 @@ import org.junit.FixMethodOrder;
import org.junit.Test; import org.junit.Test;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Test_Helper extends ExaminationTestDefaults { public class Test_20_Helper_checkTitle extends ExaminationTestDefaults {
/* Section: isAscending */
@Test @Marking(points = 3) public void test_010_isAscending_positive() {
Assert.assertTrue(Helper.isAscending(1, 2, 3));
Assert.assertFalse("Second value not greater than first", Helper.isAscending(1, 1, 3));
Assert.assertFalse("All values are strictly descending", Helper.isAscending(3, 2, 1));
}
@Test @Marking(points = 3) public void test_020_isAscending_negative() {
Assert.assertTrue(Helper.isAscending(-41, -20, 30));
Assert.assertFalse("Second value not greater than first", Helper.isAscending(-50, -50, 3));
}
/* Section: checkTitle */ /* Section: checkTitle */
...@@ -70,49 +55,4 @@ public class Test_Helper extends ExaminationTestDefaults { ...@@ -70,49 +55,4 @@ public class Test_Helper extends ExaminationTestDefaults {
Assert.assertTrue(Helper.checkTitle("You should not start with small caps")); Assert.assertTrue(Helper.checkTitle("You should not start with small caps"));
} }
/* Section: isVowel(...) */
@Test @Marking(points = 5) public void test_410_checkVowel() {
for (final char consonant: new char[]{
'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'}) {
Assert.assertFalse(Helper.isVowel(consonant));
Assert.assertFalse(Helper.isVowel(Character.toUpperCase(consonant)));
}
for (final char vowel: new char[]{'a', 'e', 'i', 'o', 'u'}) {
Assert.assertTrue(Helper.isVowel(vowel));
Assert.assertTrue(Helper.isVowel(Character.toUpperCase(vowel)));
}
}
/* Section: getNumberOfVowels(...) */
@Test @Marking(points = 2) public void test_420_getNumberOfVowels_null() {
Assert.assertEquals(0, Helper.getNumberOfVowels(null));
}
@Test @Marking(points = 2) public void test_430_getNumberOfVowels() {
Assert.assertEquals(0, Helper.getNumberOfVowels(""));
Assert.assertEquals(0, Helper.getNumberOfVowels("Thx"));
Assert.assertEquals(1, Helper.getNumberOfVowels("O"));
Assert.assertEquals(3, Helper.getNumberOfVowels("Oui"));
Assert.assertEquals(7, Helper.getNumberOfVowels("This is quite simple."));
}
/* Section: renameFileBasename */
@Test @Marking(points = 2) public void test_610_rename_noExtension() {
Assert.assertEquals("standard", Helper.renameFileBasename("standard", "standard"));
Assert.assertEquals("other", Helper.renameFileBasename("standard", "other"));
}
@Test @Marking(points = 3) public void test_620_rename_simpleExtension() {
Assert.assertEquals("doo.pdf", Helper.renameFileBasename("foo.pdf", "doo"));
Assert.assertEquals("doo.pdf", Helper.renameFileBasename(".pdf", "doo"));
}
@Test @Marking(points = 3) public void test_630_rename_complexExtension() {
Assert.assertEquals("new.tar.gz", Helper.renameFileBasename("archive.tar.gz", "new"));
Assert.assertEquals("cute.b.c.d.e.f", Helper.renameFileBasename("a.b.c.d.e.f", "cute"));
Assert.assertEquals("cute.b.c.d.e.f", Helper.renameFileBasename("a.b.c.d.e.f", "cute"));
}
} }
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test.task1;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
import de.hdm_stuttgart.mi.exam.unitmarking.Marking;
import de.hdm_stuttgart.mi.sd1.task1.Helper;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Test_30_Helper_isVowel extends ExaminationTestDefaults {
/* Section: isVowel(...) */
@Test @Marking(points = 5) public void test_410_checkVowel() {
for (final char consonant: new char[]{
'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'}) {
Assert.assertFalse(Helper.isVowel(consonant));
Assert.assertFalse(Helper.isVowel(Character.toUpperCase(consonant)));
}
for (final char vowel: new char[]{'a', 'e', 'i', 'o', 'u'}) {
Assert.assertTrue(Helper.isVowel(vowel));
Assert.assertTrue(Helper.isVowel(Character.toUpperCase(vowel)));
}
}
}
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test.task1;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
import de.hdm_stuttgart.mi.exam.unitmarking.Marking;
import de.hdm_stuttgart.mi.sd1.task1.Helper;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Test_40_Helper_getNumberOfVowels extends ExaminationTestDefaults {
@Test @Marking(points = 2) public void test_420_getNumberOfVowels_null() {
Assert.assertEquals(0, Helper.getNumberOfVowels(null));
}
@Test @Marking(points = 2) public void test_430_getNumberOfVowels() {
Assert.assertEquals(0, Helper.getNumberOfVowels(""));
Assert.assertEquals(0, Helper.getNumberOfVowels("Thx"));
Assert.assertEquals(1, Helper.getNumberOfVowels("O"));
Assert.assertEquals(3, Helper.getNumberOfVowels("Oui"));
Assert.assertEquals(7, Helper.getNumberOfVowels("This is quite simple."));
}
}
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test.task1;
import de.hdm_stuttgart.mi.exam.unitmarking.Marking;
import de.hdm_stuttgart.mi.sd1.task1.Helper;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Test_50_Helper_renameFileBasename extends ExaminationTestDefaults {
@Test @Marking(points = 2) public void test_610_rename_noExtension() {
Assert.assertEquals("standard", Helper.renameFileBasename("standard", "standard"));
Assert.assertEquals("other", Helper.renameFileBasename("standard", "other"));
}
@Test @Marking(points = 3) public void test_620_rename_simpleExtension() {
Assert.assertEquals("doo.pdf", Helper.renameFileBasename("foo.pdf", "doo"));
Assert.assertEquals("doo.pdf", Helper.renameFileBasename(".pdf", "doo"));
}
@Test @Marking(points = 3) public void test_630_rename_complexExtension() {
Assert.assertEquals("new.tar.gz", Helper.renameFileBasename("archive.tar.gz", "new"));
Assert.assertEquals("cute.b.c.d.e.f", Helper.renameFileBasename("a.b.c.d.e.f", "cute"));
Assert.assertEquals("cute.b.c.d.e.f", Helper.renameFileBasename("a.b.c.d.e.f", "cute"));
}
}
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test; package de.hdm_stuttgart.mi.sd1.test;
import de.hdm_stuttgart.mi.exam.unitmarking.RunTests; import de.hdm_stuttgart.mi.exam.unitmarking.RunTests;
import de.hdm_stuttgart.mi.sd1.test.task1.Test_HelperArray; import de.hdm_stuttgart.mi.sd1.test.task1.*;
import de.hdm_stuttgart.mi.sd1.test.task1.Test_Helper;
import de.hdm_stuttgart.mi.sd1.test.task2.Test_ChangeAmount; import de.hdm_stuttgart.mi.sd1.test.task2.Test_ChangeAmount;
public class ShowReachedPoints { public class ShowReachedPoints {
...@@ -14,11 +13,17 @@ public class ShowReachedPoints { ...@@ -14,11 +13,17 @@ public class ShowReachedPoints {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
RunTests.exec( RunTests.exec(
"Aufgabe 1" "Task 1"
, Test_Helper.class , Test_10_Helper_isAscending.class
, Test_HelperArray.class , Test_20_Helper_checkTitle.class
); , Test_30_Helper_isVowel.class
, Test_40_Helper_getNumberOfVowels.class
, Test_50_Helper_renameFileBasename.class
RunTests.exec("Aufgabe 2", Test_ChangeAmount.class); , Test_110_HelperArray_getAlphabeticalFollowers.class
, Test_120_HelperArray_getLeaders.class
);
RunTests.exec("Task 2", Test_ChangeAmount.class);
} }
} }
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test.task1;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
import de.hdm_stuttgart.mi.exam.unitmarking.Marking;
import de.hdm_stuttgart.mi.sd1.task1.Helper;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Test_10_Helper_isAscending extends ExaminationTestDefaults {
/* Section: isAscending */
@Test @Marking(points = 3) public void test_010_isAscending_positive() {
Assert.assertTrue(Helper.isAscending(1, 2, 3));
Assert.assertFalse("Second value not greater than first", Helper.isAscending(1, 1, 3));
Assert.assertFalse("All values are strictly descending", Helper.isAscending(3, 2, 1));
}
@Test @Marking(points = 3) public void test_020_isAscending_negative() {
Assert.assertTrue(Helper.isAscending(-41, -20, 30));
Assert.assertFalse("Second value not greater than first", Helper.isAscending(-50, -50, 3));
}
}
\ No newline at end of file
...@@ -13,8 +13,7 @@ import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getAlphabeticalFollowers ...@@ -13,8 +13,7 @@ import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getAlphabeticalFollowers
import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getLeaders; import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getLeaders;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@SuppressWarnings({"UnusedDeclaration"}) public class Test_110_HelperArray_getAlphabeticalFollowers extends ExaminationTestDefaults {
public class Test_HelperArray extends ExaminationTestDefaults {
private static void assertArrayEmpty(final String[] values){ private static void assertArrayEmpty(final String[] values){
Assert.assertArrayEquals( Assert.assertArrayEquals(
...@@ -22,8 +21,6 @@ public class Test_HelperArray extends ExaminationTestDefaults { ...@@ -22,8 +21,6 @@ public class Test_HelperArray extends ExaminationTestDefaults {
values); values);
} }
/* Section: getAlphabeticalFollowers */
@Test @Marking(points = 4) public void test_400_testSpecialCases() { @Test @Marking(points = 4) public void test_400_testSpecialCases() {
assertArrayEmpty(getAlphabeticalFollowers(null, null)); assertArrayEmpty(getAlphabeticalFollowers(null, null));
...@@ -51,7 +48,7 @@ public class Test_HelperArray extends ExaminationTestDefaults { ...@@ -51,7 +48,7 @@ public class Test_HelperArray extends ExaminationTestDefaults {
Assert.assertArrayEquals(expected, result); Assert.assertArrayEquals(expected, result);
Assert.assertArrayEquals(valuesCopy, values); // Original values untouched? Assert.assertArrayEquals("Error: Original array value modifications", valuesCopy, values);
} }
...@@ -89,28 +86,4 @@ public class Test_HelperArray extends ExaminationTestDefaults { ...@@ -89,28 +86,4 @@ public class Test_HelperArray extends ExaminationTestDefaults {
assertFilter(values, values, ""); assertFilter(values, values, "");
assertFilter(values, values, "alph"); assertFilter(values, values, "alph");
} }
/* Section: getLeaders */
@Test public void test_600_singleLeader() {
Assert.assertArrayEquals(new int[]{-3}, getLeaders(new int[]{-3}));
Assert.assertArrayEquals(new int[]{1, 0}, getLeaders(new int[]{1, 0}));
Assert.assertArrayEquals(new int[]{1}, getLeaders(new int[]{0, 1}));
}
@Test public void test_620_edgeDuplicate() {
Assert.assertArrayEquals(new int[]{3, 3}, getLeaders(new int[]{1, 3, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{4, 3}, getLeaders(new int[]{1, 4, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{3}, getLeaders(new int[]{1, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{3, 3}, getLeaders(new int[]{3, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{6, 3}, getLeaders(new int[]{6, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{17, 5, 2}, getLeaders(new int[]{16, 17, 4, 3, 5, 2}));
}
@Test public void test_640_all() {
Assert.assertArrayEquals(new int[]{5,4,3,2,1,0}, getLeaders(new int[]{5,4,3,2,1,0}));
Assert.assertArrayEquals(new int[]{4,4,4,4,4,4,4}, getLeaders(new int[]{4,4,4,4,4,4,4}));
}
} }
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test.task1;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
import de.hdm_stuttgart.mi.exam.unitmarking.Marking;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.util.Arrays;
import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getAlphabeticalFollowers;
import static de.hdm_stuttgart.mi.sd1.task1.HelperArray.getLeaders;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Test_120_HelperArray_getLeaders extends ExaminationTestDefaults {
@Test public void test_600_singleLeader() {
Assert.assertArrayEquals(new int[]{-3}, getLeaders(new int[]{-3}));
Assert.assertArrayEquals(new int[]{1, 0}, getLeaders(new int[]{1, 0}));
Assert.assertArrayEquals(new int[]{1}, getLeaders(new int[]{0, 1}));
}
@Test public void test_620_edgeDuplicate() {
Assert.assertArrayEquals(new int[]{3, 3}, getLeaders(new int[]{1, 3, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{4, 3}, getLeaders(new int[]{1, 4, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{3}, getLeaders(new int[]{1, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{3, 3}, getLeaders(new int[]{3, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{6, 3}, getLeaders(new int[]{6, 2, -2, 0, 3}));
Assert.assertArrayEquals(new int[]{17, 5, 2}, getLeaders(new int[]{16, 17, 4, 3, 5, 2}));
}
@Test public void test_640_all() {
Assert.assertArrayEquals(new int[]{5,4,3,2,1,0}, getLeaders(new int[]{5,4,3,2,1,0}));
Assert.assertArrayEquals(new int[]{4,4,4,4,4,4,4}, getLeaders(new int[]{4,4,4,4,4,4,4}));
}
}
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test.task1; package de.hdm_stuttgart.mi.sd1.test.task1;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
import de.hdm_stuttgart.mi.exam.unitmarking.Marking; import de.hdm_stuttgart.mi.exam.unitmarking.Marking;
import de.hdm_stuttgart.mi.sd1.task1.Helper; import de.hdm_stuttgart.mi.sd1.task1.Helper;
import org.junit.Assert; import org.junit.Assert;
...@@ -7,24 +8,8 @@ import org.junit.FixMethodOrder; ...@@ -7,24 +8,8 @@ import org.junit.FixMethodOrder;
import org.junit.Test; import org.junit.Test;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Test_Helper extends ExaminationTestDefaults { public class Test_20_Helper_checkTitle extends ExaminationTestDefaults {
/* Section: isAscending */
@Test @Marking(points = 3) public void test_010_isAscending_positive() {
Assert.assertTrue(Helper.isAscending(1, 2, 3));
Assert.assertFalse("Second value not greater than first", Helper.isAscending(1, 1, 3));
Assert.assertFalse("All values are strictly descending", Helper.isAscending(3, 2, 1));
}
@Test @Marking(points = 3) public void test_020_isAscending_negative() {
Assert.assertTrue(Helper.isAscending(-41, -20, 30));
Assert.assertFalse("Second value not greater than first", Helper.isAscending(-50, -50, 3));
}
/* Section: checkTitle */ /* Section: checkTitle */
...@@ -70,49 +55,4 @@ public class Test_Helper extends ExaminationTestDefaults { ...@@ -70,49 +55,4 @@ public class Test_Helper extends ExaminationTestDefaults {
Assert.assertTrue(Helper.checkTitle("You should not start with small caps")); Assert.assertTrue(Helper.checkTitle("You should not start with small caps"));
} }
/* Section: isVowel(...) */
@Test @Marking(points = 5) public void test_410_checkVowel() {
for (final char consonant: new char[]{
'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'}) {
Assert.assertFalse(Helper.isVowel(consonant));
Assert.assertFalse(Helper.isVowel(Character.toUpperCase(consonant)));
}
for (final char vowel: new char[]{'a', 'e', 'i', 'o', 'u'}) {
Assert.assertTrue(Helper.isVowel(vowel));
Assert.assertTrue(Helper.isVowel(Character.toUpperCase(vowel)));
}
}
/* Section: getNumberOfVowels(...) */
@Test @Marking(points = 2) public void test_420_getNumberOfVowels_null() {
Assert.assertEquals(0, Helper.getNumberOfVowels(null));
}
@Test @Marking(points = 2) public void test_430_getNumberOfVowels() {
Assert.assertEquals(0, Helper.getNumberOfVowels(""));
Assert.assertEquals(0, Helper.getNumberOfVowels("Thx"));
Assert.assertEquals(1, Helper.getNumberOfVowels("O"));
Assert.assertEquals(3, Helper.getNumberOfVowels("Oui"));
Assert.assertEquals(7, Helper.getNumberOfVowels("This is quite simple."));
}
/* Section: renameFileBasename */
@Test @Marking(points = 2) public void test_610_rename_noExtension() {
Assert.assertEquals("standard", Helper.renameFileBasename("standard", "standard"));
Assert.assertEquals("other", Helper.renameFileBasename("standard", "other"));
}
@Test @Marking(points = 3) public void test_620_rename_simpleExtension() {
Assert.assertEquals("doo.pdf", Helper.renameFileBasename("foo.pdf", "doo"));
Assert.assertEquals("doo.pdf", Helper.renameFileBasename(".pdf", "doo"));
}
@Test @Marking(points = 3) public void test_630_rename_complexExtension() {
Assert.assertEquals("new.tar.gz", Helper.renameFileBasename("archive.tar.gz", "new"));
Assert.assertEquals("cute.b.c.d.e.f", Helper.renameFileBasename("a.b.c.d.e.f", "cute"));
Assert.assertEquals("cute.b.c.d.e.f", Helper.renameFileBasename("a.b.c.d.e.f", "cute"));
}
} }
\ No newline at end of file
package de.hdm_stuttgart.mi.sd1.test.task1;
import de.hdm_stuttgart.mi.exam.unitmarking.ExaminationTestDefaults;
import de.hdm_stuttgart.mi.exam.unitmarking.Marking;
import de.hdm_stuttgart.mi.sd1.task1.Helper;