This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Bumped version to 3.0.3 - Added simple test for TopicalSort - Added cache for Rank all permissions calculation - Added rank cache invalidation - Restructered main help command. Instead of showing "Name: syntax" it now shows "syntax description"
- Loading branch information
Showing
18 changed files
with
122 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/test/java/de/timmi6790/statsbotdiscord/utilities/sorting/TopicalSortTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package de.timmi6790.statsbotdiscord.utilities.sorting; | ||
|
||
import de.timmi6790.statsbotdiscord.datatypes.ListBuilder; | ||
import de.timmi6790.statsbotdiscord.exceptions.TopicalSortCycleException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class TopicalSortTest { | ||
@Test | ||
void simplePathSort() throws TopicalSortCycleException { | ||
final List<Integer> values = Arrays.asList(10, 2, 5, 1, 4, 3, 8, 6, 7, 9); | ||
final List<TopicalSort.Dependency> dependencies = new ListBuilder<TopicalSort.Dependency>(ArrayList::new) | ||
.add(new TopicalSort.Dependency(0, 9)) | ||
.add(new TopicalSort.Dependency(9, 6)) | ||
.add(new TopicalSort.Dependency(6, 8)) | ||
.add(new TopicalSort.Dependency(8, 7)) | ||
.add(new TopicalSort.Dependency(7, 2)) | ||
.add(new TopicalSort.Dependency(2, 4)) | ||
.add(new TopicalSort.Dependency(4, 5)) | ||
.add(new TopicalSort.Dependency(5, 1)) | ||
.add(new TopicalSort.Dependency(1, 3)) | ||
.build(); | ||
|
||
final TopicalSort<Integer> topicalSort = new TopicalSort<>(values, dependencies); | ||
final List<Integer> sortedList = topicalSort.sort(); | ||
|
||
final List<Integer> controlList = IntStream.range(1, 11) | ||
.boxed() | ||
.collect(Collectors.toList()); | ||
assertThat(sortedList).isEqualTo(controlList); | ||
} | ||
|
||
@Test | ||
void simpleLoopDetectionCheck() { | ||
final List<Integer> values = Arrays.asList(1, 2); | ||
final List<TopicalSort.Dependency> dependencies = new ListBuilder<TopicalSort.Dependency>(ArrayList::new) | ||
.add(new TopicalSort.Dependency(0, 1)) | ||
.add(new TopicalSort.Dependency(1, 0)) | ||
.build(); | ||
|
||
final TopicalSort<Integer> topicalSort = new TopicalSort<>(values, dependencies); | ||
assertThrows(TopicalSortCycleException.class, topicalSort::sort); | ||
} | ||
} |