-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Added Minecraft GameTests for automated testing ## Changes - **Change 1**: Added Gametests in the test package <!-- - **Change 2**: Description of what was changed. --> <!-- - **Change 3**: Description of what was changed. --> ## How has this been tested? <!-- Describe the tests that you ran to verify your changes. --> ## Screenshots (if applicable) <!-- Add screenshots to explain the visual impact of the changes. --> ## Type of Change - [ ] Bug fix - [x] New feature - [ ] Cleanup - [ ] Breaking change - [ ] Documentation update ## Checklist - [x] My code follows the style guidelines of this project. [Contributing](https://github.com/MeAlam1/BlueLib/blob/1.21/CONTRIBUTING.md) - [x] I have performed a self-review of my own code. - [x] I have commented my code following the guidelines. [Contributing](https://github.com/MeAlam1/BlueLib/blob/1.21/CONTRIBUTING.md) - [x] My changes generate no new warnings. ## Related Issues <!-- List any issues that this PR is related to or closes. -->
- Loading branch information
Showing
16 changed files
with
448 additions
and
8 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
12 changes: 12 additions & 0 deletions
12
common/src/main/java/software/bluelib/test/ExampleTest.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,12 @@ | ||
package software.bluelib.test; | ||
|
||
import net.minecraft.gametest.framework.GameTest; | ||
import net.minecraft.gametest.framework.GameTestHelper; | ||
|
||
public class ExampleTest { | ||
|
||
@GameTest | ||
public static void alwaysSuccess(GameTestHelper pHelper) { | ||
pHelper.succeed(); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
common/src/main/java/software/bluelib/test/markdown/All.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 software.bluelib.test.markdown; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import software.bluelib.test.utils.MessageUtils; | ||
|
||
public class All { | ||
|
||
private static final List<String> STYLES = List.of( | ||
"**bold**", // Bold | ||
"*italic*", // Italic | ||
"__Underline__", // Underline | ||
"~~Strikethrough~~", // Strikethrough | ||
"[Hyperlink](https://www.curseforge.com/minecraft/mc-mods/bluelib)", // Hyperlink | ||
"-#" + MessageUtils.getRandomHex() + " -(Color)" // Color | ||
); | ||
|
||
public static void testAllCombinations(GameTestHelper pHelper) { | ||
List<List<String>> combinations = generateCombinations(); | ||
|
||
for (List<String> combination : combinations) { | ||
String styledMessage = buildMessage(combination); | ||
MessageUtils.sendMessageToPlayers(pHelper, styledMessage); | ||
} | ||
} | ||
|
||
private static List<List<String>> generateCombinations() { | ||
List<List<String>> combinations = new ArrayList<>(); | ||
int n = All.STYLES.size(); | ||
int totalCombinations = 1 << n; | ||
|
||
for (int i = 0; i < totalCombinations; i++) { | ||
List<String> combination = new ArrayList<>(); | ||
for (int j = 0; j < n; j++) { | ||
if ((i & (1 << j)) != 0) { | ||
combination.add(All.STYLES.get(j)); | ||
} | ||
} | ||
combinations.add(combination); | ||
} | ||
return combinations; | ||
} | ||
|
||
private static String buildMessage(List<String> combination) { | ||
StringBuilder messageBuilder = new StringBuilder("§6 This is a test: §r "); | ||
for (String style : combination) { | ||
messageBuilder.append(style).append(" "); | ||
} | ||
return messageBuilder.toString().trim(); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
common/src/main/java/software/bluelib/test/markdown/Markdown.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,87 @@ | ||
package software.bluelib.test.markdown; | ||
|
||
import net.minecraft.gametest.framework.GameTest; | ||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import software.bluelib.test.markdown.syntax.*; | ||
|
||
public class Markdown { | ||
|
||
@GameTest | ||
public static void bold(GameTestHelper pHelper) { | ||
pHelper.succeedIf(() -> { | ||
Bold.bold(pHelper); | ||
Bold.boldItalic(pHelper); | ||
Bold.boldUnderline(pHelper); | ||
Bold.boldStrikethrough(pHelper); | ||
Bold.boldHyperlink(pHelper); | ||
Bold.boldColor(pHelper); | ||
}); | ||
} | ||
|
||
@GameTest | ||
public static void italic(GameTestHelper pHelper) { | ||
pHelper.succeedIf(() -> { | ||
Italic.italic(pHelper); | ||
Italic.italicBold(pHelper); | ||
Italic.italicUnderline(pHelper); | ||
Italic.italicStrikethrough(pHelper); | ||
Italic.italicHyperlink(pHelper); | ||
Italic.italicColor(pHelper); | ||
}); | ||
} | ||
|
||
@GameTest | ||
public static void underline(GameTestHelper pHelper) { | ||
pHelper.succeedIf(() -> { | ||
Underline.underline(pHelper); | ||
Underline.underlineBold(pHelper); | ||
Underline.underlineItalic(pHelper); | ||
Underline.underlineStrikethrough(pHelper); | ||
Underline.underlineHyperlink(pHelper); | ||
Underline.underlineColor(pHelper); | ||
}); | ||
} | ||
|
||
@GameTest | ||
public static void strikethrough(GameTestHelper pHelper) { | ||
pHelper.succeedIf(() -> { | ||
Strikethrough.strikethrough(pHelper); | ||
Strikethrough.strikethroughBold(pHelper); | ||
Strikethrough.strikethroughItalic(pHelper); | ||
Strikethrough.strikethroughUnderline(pHelper); | ||
Strikethrough.strikethroughHyperlink(pHelper); | ||
Strikethrough.strikethroughColor(pHelper); | ||
}); | ||
} | ||
|
||
@GameTest | ||
public static void hyperlink(GameTestHelper pHelper) { | ||
pHelper.succeedIf(() -> { | ||
Hyperlink.hyperlink(pHelper); | ||
Hyperlink.hyperlinkBold(pHelper); | ||
Hyperlink.hyperlinkItalic(pHelper); | ||
Hyperlink.hyperlinkUnderline(pHelper); | ||
Hyperlink.hyperlinkStrikethrough(pHelper); | ||
Hyperlink.hyperlinkColor(pHelper); | ||
}); | ||
} | ||
|
||
@GameTest | ||
public static void color(GameTestHelper pHelper) { | ||
pHelper.succeedIf(() -> { | ||
Color.color(pHelper); | ||
Color.colorBold(pHelper); | ||
Color.colorItalic(pHelper); | ||
Color.colorUnderline(pHelper); | ||
Color.colorStrikethrough(pHelper); | ||
Color.colorHyperlink(pHelper); | ||
}); | ||
} | ||
|
||
@GameTest | ||
public static void all(GameTestHelper pHelper) { | ||
pHelper.succeedIf(() -> { | ||
All.testAllCombinations(pHelper); | ||
}); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
common/src/main/java/software/bluelib/test/markdown/syntax/Bold.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,31 @@ | ||
package software.bluelib.test.markdown.syntax; | ||
|
||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import software.bluelib.test.utils.MessageUtils; | ||
|
||
public class Bold { | ||
|
||
public static void bold(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a bold test: §r **bold**"); | ||
} | ||
|
||
public static void boldItalic(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a bold/italic test: §r **bold** *italic*"); | ||
} | ||
|
||
public static void boldUnderline(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a bold/italic test: §r **bold** __Underline__"); | ||
} | ||
|
||
public static void boldStrikethrough(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a bold/italic test: §r **bold** ~~Strikethrough~~"); | ||
} | ||
|
||
public static void boldHyperlink(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a bold/italic test: §r **bold** [Hyperlink](https://www.curseforge.com/minecraft/mc-mods/bluelib)"); | ||
} | ||
|
||
public static void boldColor(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a bold/italic test: §r **bold** -#" + MessageUtils.getRandomHex() + " -(Color)"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
common/src/main/java/software/bluelib/test/markdown/syntax/Color.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,31 @@ | ||
package software.bluelib.test.markdown.syntax; | ||
|
||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import software.bluelib.test.utils.MessageUtils; | ||
|
||
public class Color { | ||
|
||
public static void color(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a color test: §r -#" + MessageUtils.getRandomHex() + " -(Color)"); | ||
} | ||
|
||
public static void colorBold(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a color/bold test: §r -#" + MessageUtils.getRandomHex() + " -(Color) **bold**"); | ||
} | ||
|
||
public static void colorItalic(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a color/italic test: §r -#" + MessageUtils.getRandomHex() + " -(Color) *italic*"); | ||
} | ||
|
||
public static void colorUnderline(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a color/underline test: §r -#" + MessageUtils.getRandomHex() + " -(Color) __Underline__"); | ||
} | ||
|
||
public static void colorStrikethrough(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a color/strikethrough test: §r -#" + MessageUtils.getRandomHex() + " -(Color) ~~Strikethrough~~"); | ||
} | ||
|
||
public static void colorHyperlink(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a color/hyperlink test: §r -#" + MessageUtils.getRandomHex() + " -(Color) [Hyperlink](https://www.curseforge.com/minecraft/mc-mods/bluelib)"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
common/src/main/java/software/bluelib/test/markdown/syntax/Hyperlink.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,31 @@ | ||
package software.bluelib.test.markdown.syntax; | ||
|
||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import software.bluelib.test.utils.MessageUtils; | ||
|
||
public class Hyperlink { | ||
|
||
public static void hyperlink(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a hyperlink test: §r [Hyperlink](https://www.curseforge.com/minecraft/mc-mods/bluelib)"); | ||
} | ||
|
||
public static void hyperlinkBold(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a hyperlink/bold test: §r [Hyperlink](https://modrinth.com/mod/bluelib) **bold**"); | ||
} | ||
|
||
public static void hyperlinkItalic(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an hyperlink/italic test: §r [Hyperlink](https://www.curseforge.com/minecraft/mc-mods/bluelib-common) *italic*"); | ||
} | ||
|
||
public static void hyperlinkUnderline(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an hyperlink/underline test: §r [Hyperlink](https://github.com/MeAlam1/BlueLib) __Underline__"); | ||
} | ||
|
||
public static void hyperlinkStrikethrough(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a hyperlink/strikethrough test: §r [Hyperlink](https://github.com/users/MeAlam1/projects/6) ~~Strikethrough~~"); | ||
} | ||
|
||
public static void hyperlinkColor(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a hyperlink/color test: §r [Hyperlink](https://github.com/MeAlam1/BlueLib/issues) -#" + MessageUtils.getRandomHex() + " -(Color)"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
common/src/main/java/software/bluelib/test/markdown/syntax/Italic.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,31 @@ | ||
package software.bluelib.test.markdown.syntax; | ||
|
||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import software.bluelib.test.utils.MessageUtils; | ||
|
||
public class Italic { | ||
|
||
public static void italic(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an italic test: §r *italic*"); | ||
} | ||
|
||
public static void italicBold(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a italic/bold test: §r *italic* **bold**"); | ||
} | ||
|
||
public static void italicUnderline(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an italic/underline test: §r *italic* __Underline__"); | ||
} | ||
|
||
public static void italicStrikethrough(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an italic/strikethrough test: §r *italic* ~~Strikethrough~~"); | ||
} | ||
|
||
public static void italicHyperlink(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an italic/hyperlink test: §r *italic* [Hyperlink](https://www.curseforge.com/minecraft/mc-mods/bluelib)"); | ||
} | ||
|
||
public static void italicColor(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an italic/color test: §r *italic* -#" + MessageUtils.getRandomHex() + " -(Color)"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
common/src/main/java/software/bluelib/test/markdown/syntax/Strikethrough.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,31 @@ | ||
package software.bluelib.test.markdown.syntax; | ||
|
||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import software.bluelib.test.utils.MessageUtils; | ||
|
||
public class Strikethrough { | ||
|
||
public static void strikethrough(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a strikethrough test: §r ~~Strikethrough~~"); | ||
} | ||
|
||
public static void strikethroughBold(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a strikethrough/bold test: §r ~~Strikethrough~~ **bold**"); | ||
} | ||
|
||
public static void strikethroughItalic(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an strikethrough/italic test: §r ~~Strikethrough~~ *italic*"); | ||
} | ||
|
||
public static void strikethroughUnderline(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an strikethrough/underline test: §r ~~Strikethrough~~ __Underline__"); | ||
} | ||
|
||
public static void strikethroughHyperlink(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a strikethrough/hyperlink test: §r ~~Strikethrough~~ [Hyperlink](https://www.curseforge.com/minecraft/mc-mods/bluelib)"); | ||
} | ||
|
||
public static void strikethroughColor(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a strikethrough/color test: §r ~~Strikethrough~~ -#" + MessageUtils.getRandomHex() + " -(Color)"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
common/src/main/java/software/bluelib/test/markdown/syntax/Underline.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,31 @@ | ||
package software.bluelib.test.markdown.syntax; | ||
|
||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import software.bluelib.test.utils.MessageUtils; | ||
|
||
public class Underline { | ||
|
||
public static void underline(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an underline test: §r __Underline__"); | ||
} | ||
|
||
public static void underlineBold(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is a underline/bold test: §r __Underline__ **bold**"); | ||
} | ||
|
||
public static void underlineItalic(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an underline/italic test: §r __Underline__ *italic*"); | ||
} | ||
|
||
public static void underlineStrikethrough(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an underline/strikethrough test: §r __Underline__ ~~Strikethrough~~"); | ||
} | ||
|
||
public static void underlineHyperlink(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an underline/hyperlink test: §r __Underline__ [Hyperlink](https://www.curseforge.com/minecraft/mc-mods/bluelib)"); | ||
} | ||
|
||
public static void underlineColor(GameTestHelper pHelper) { | ||
MessageUtils.sendMessageToPlayers(pHelper, "§6 This is an underline/color test: §r __Underline__ -#" + MessageUtils.getRandomHex() + " -(Color)"); | ||
} | ||
} |
Oops, something went wrong.