First attempt at spring boot autoconfiguration

This commit is contained in:
2024-08-20 20:25:25 +02:00
parent e051ca803c
commit 3ccc0dd265
20 changed files with 247 additions and 25 deletions

View File

@@ -0,0 +1,12 @@
package be.seeseemelk.llamascript;
import org.junit.jupiter.api.BeforeEach;
public class AbstractLlamaTest {
protected LlamaScript llama;
@BeforeEach
void setUp() {
llama = new LLamaScriptFactory().build();
}
}

View File

@@ -0,0 +1,26 @@
package be.seeseemelk.llamascript;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
public class BooleanTests extends AbstractLlamaTest {
@ParameterizedTest
@ValueSource(ints = {0, 1, 2, 3, 4, 5})
void isEven(int number) {
boolean isEven = llama.evalBool("Return true if the number is even", number);
assertThat(isEven, equalTo(number % 2 == 0));
}
@Test
void isABuilding() {
boolean isBuilding = llama.evalBool("Return true if the argument is a building or skyscraper", "Dalai Lama");
assertThat(isBuilding, equalTo(false));
isBuilding = llama.evalBool("Return true if the argument is a building or skyscraper", "Burj Khalifa");
assertThat(isBuilding, equalTo(true));
}
}

View File

@@ -0,0 +1,41 @@
package be.seeseemelk.llamascript;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
public class IntegerTests extends AbstractLlamaTest {
@Test
void canIncrementNumber() {
int value = llama.evalInt("Increment the number", 4);
assertThat(value, equalTo(5));
}
@Test
void canMultiply() {
int value = llama.evalInt("Multiply the numbers", 2, 3);
assertThat(value, equalTo(2*3));
}
@Test
void canMax() {
int value = llama.evalInt("Select the largest number", -2, 8);
assertThat(value, equalTo(8));
}
@Test
void canDoWeirdStuff() {
int value = llama.evalInt("Select the number with the most '5's in it.", 12, 5, 1023978, 158525);
assertThat(value, equalTo(158525));
}
@Test
void givePositivity() {
int value = llama.evalInt("If the string is something positive, return 1. Else, return 0.", "I like rainbows");
assertThat(value, equalTo(1));
value = llama.evalInt("If the string is something positive, return 1. Else, return 0.", "Death to all");
assertThat(value, equalTo(0));
}
}

View File

@@ -0,0 +1,44 @@
package be.seeseemelk.llamascript;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
public class StringTests extends AbstractLlamaTest {
@Test
void canUppercase() {
String value = llama.evalString("Return the string in uppercase", "Cat");
assertThat(value, equalTo("CAT"));
}
@Test
void canLowercase() {
String value = llama.evalString("Return the string in lowercase", "Cat");
assertThat(value, equalTo("cat"));
}
@Test
void canInvert() {
String value = llama.evalString("Return the string backwards", "Cat");
assertThat(value, equalTo("taC"));
}
@Test
void canSelectLongest() {
String value = llama.evalString("Return the longest string", "Cat", "Dog", "Horse");
assertThat(value, equalTo("Horse"));
}
@Test
void canDoWeirdStuff() {
String value = llama.evalString("Return the string that does not fit", "Cat", "Dog", "Horse", "Bicycle");
assertThat(value, equalTo("Bicycle"));
}
@Test
void canDoReallyWeirdStuff() {
String value = llama.evalString("Sort the letters alphabetically", "horse");
assertThat(value, equalTo("ehors"));
}
}