Skip to content

Commit

Permalink
Update manifold
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberpwnn committed Jul 5, 2022
1 parent 4fed138 commit 7fc9167
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ dependencies {
implementation 'systems.manifold:manifold-rt:2022.1.18'
implementation 'com.google.dagger:dagger:2.40.1'
implementation 'org.reflections:reflections:0.10.2'
api 'systems.manifold:manifold-rt:2022.1.14'
api 'systems.manifold:manifold-ext-rt:2022.1.14'
api 'systems.manifold:manifold-rt:2022.1.18'
api 'systems.manifold:manifold-ext-rt:2022.1.18'
api 'it.unimi.dsi:fastutil:8.5.8'
api 'com.google.guava:guava:31.1-jre'
api 'org.apache.commons:commons-lang3:3.12.0'
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/Amulet/extensions/java/lang/String/XString.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,46 @@ public static String lower(@This String s) {
return s.toLowerCase(Locale.ROOT);
}

public static double toDouble(@This String s) {
return Double.parseDouble(s);
}
public static double toDouble(@This String s, double or) {
try{
return toDouble(s);
}

catch(NumberFormatException e){
return or;
}
}

public static int toInt(@This String s) {
return Integer.parseInt(s);
}
public static int toInt(@This String s, int or) {
try{
return toInt(s);
}

catch(NumberFormatException e){
return or;
}
}

public static long toLong(@This String s) {
return Long.parseLong(s);
}
public static long toLong(@This String s, long or) {
try{
return toLong(s);
}

catch(NumberFormatException e){
return or;
}
}


public static String replaceAbs(@This String s, String find, String replace) {
return s.replaceAll("\\Q" + find + "\\E", replace);
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/art/arcane/amulet/test/unit/SugarTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

import art.arcane.amulet.MagicalSugar;
import art.arcane.amulet.geometry.Vec;
import art.arcane.amulet.io.nbt.nbt.tag.CompoundTag;
import art.arcane.amulet.io.nbt.objects.NBTObjectSerializer;
import art.arcane.amulet.io.nbt.objects.UnserializableClassException;
import art.arcane.amulet.range.IntegerRange;
import manifold.ext.rt.RuntimeMethods;
import org.junit.jupiter.api.Assertions;
Expand All @@ -40,6 +43,13 @@ public void testTime() {
assertEquals(TimeUnit.SECONDS.toMillis(30) + TimeUnit.MINUTES.toMillis(25), 30seconds + (25minutes));
}

@Test
public void testParsing() {
assertEquals(5.774, "5.774".toDouble());
assertEquals(-1, "xxx".toInt(-1));
assertEquals(7L, "7".toLong());
}

@SuppressWarnings("ConstantConditions")
@Test
public void testNullSafe() {
Expand Down

0 comments on commit 7fc9167

Please sign in to comment.