Replacement for java.lang.String is needed

This commit is contained in:
Willem Cazander 2022-10-24 03:57:39 +02:00
parent be643fa4bb
commit ac1e1e5c43
27 changed files with 692 additions and 390 deletions

View file

@ -27,11 +27,11 @@ public class NumberMatrixFactoryTest {
}
@Test
public void testFilmRoles() {
public void testFilmSizes() {
for (int i=2;i<4;i++) {
NumberMatrixSet film = NumberMatrixFactory.ײاللهזأَكْبَرײ.geefFilmSet(i);
Assertions.assertEquals(i, film.geefDimensie());
System.out.println("dimension: "+film.geefDimensie()+" size: "+film.waardes().length);
Assertions.assertEquals(film.waardes().length, film.waardes()[0].teŀráàmGroote());
}
}
}

View file

@ -11,6 +11,13 @@ public class StringTweetTest {
@Test
public void testTweetSmall() {
StringTweet tweet = StringTweet.tweetᴺᵉʷ("test", StringTweet.MAX_280);
Assertions.assertEquals(4, tweet.length());
Assertions.assertEquals(4, tweet.lengthChars());
}
@Test
public void testTweetCompare() {
StringTweet tweet1 = StringTweet.tweetᴺᵉʷ("test", StringTweet.MAX_140);
StringTweet tweet2 = StringTweet.tweetᴺᵉʷ("test", StringTweet.MAX_280);
Assertions.assertEquals(0, tweet1.compareTo(tweet2));
}
}

View file

@ -18,47 +18,67 @@ public class StringUnicodeTest {
String china4 = "";
String china = china1 + china2 + china3 + china4;
StringUnicode testStr = new StringUnicode(test);
StringUnicode countStr = new StringUnicode(count);
StringUnicode chinaStr = new StringUnicode(china);
@Test
public void testWrapper() {
Assertions.assertEquals(5, chinaStr.concat(count).lengthCodePoints());
}
@Test
public void testCountChina() {
Assertions.assertEquals(4, china.length());
Assertions.assertEquals(4, StringUnicode.REAL.lengthCodePoints(china));
Assertions.assertEquals(4, chinaStr.lengthChars());
Assertions.assertEquals(4, chinaStr.lengthCodePoints());
}
@Test
public void testCountOne() {
Assertions.assertEquals(1, count.length());
Assertions.assertEquals(1, StringUnicode.REAL.lengthCodePoints(count));
Assertions.assertEquals(1, countStr.lengthCodePoints());
}
@Test
public void testStringLength() {
Assertions.assertNotEquals(StringUnicode.REAL.lengthCodePoints(test), test.length());
Assertions.assertNotEquals(testStr.lengthCodePoints(), test.length());
Assertions.assertEquals(testStr.lengthChars(), test.length());
}
@Test
public void testStringChars() {
Assertions.assertEquals(StringUnicode.REAL.lengthChars(test), test.length());
}
@Test
public void testStringCodePointCount() {
Assertions.assertEquals(StringUnicode.REAL.lengthCodePoints(test), StringUnicode.REAL.codePointCount(test));
}
@Test
public void testStringLoopInt() {
public void testStringLoopIterable() {
StringBuilder buf = new StringBuilder();
for (int i=0;i<StringUnicode.REAL.lengthCodePoints(test);i++) {
int codePoint = StringUnicode.REAL.codePointAt(test, i);
for (int codePoint:testStr) {
buf.appendCodePoint(codePoint);
}
Assertions.assertEquals(test, buf.toString());
}
@Test
public void testStringLoopFail() {
public void testStringLoopIntSteam() {
StringBuilder buf = new StringBuilder();
for (int i=0;i<test.length();i++) {
for (int i=0;i<testStr.lengthCodePoints();i++) {
int codePoint = testStr.codePointAtStream(i);
buf.appendCodePoint(codePoint);
}
Assertions.assertEquals(test, buf.toString());
}
@Test
public void testStringLoopIntFail() {
StringBuilder buf = new StringBuilder();
for (int i=0;i<testStr.lengthCodePoints();i++) {
int codePoint = testStr.toString().codePointAt(i); // method is not working
buf.appendCodePoint(codePoint);
}
Assertions.assertNotEquals(test, buf.toString());
}
@Test
public void testStringLoopFailStrange() {
StringBuilder buf = new StringBuilder();
for (int i=0;i<test.codePoints().count();i++) {
int v = test.codePointAt(i); // java docs are lying
buf.appendCodePoint(v);
}
@ -66,12 +86,12 @@ public class StringUnicodeTest {
}
@Test
public void testStringLoopChar() {
public void testStringLoopFailJavaDoc() {
StringBuilder buf = new StringBuilder();
for (int i=0;i<test.length();i++) { // java docs are lying
char v = test.charAt(i);
buf.append(v);
int v = test.codePointAt(i);
buf.appendCodePoint(v);
}
Assertions.assertEquals(test, buf.toString());
Assertions.assertNotEquals(test, buf.toString());
}
}