feat: Using text blocks instead of String literals (#2791)

This commit is contained in:
Manoj Chowdary
2024-03-10 15:09:25 +05:30
committed by GitHub
parent 90f5b38a45
commit e377047a69
10 changed files with 87 additions and 48 deletions
@@ -44,6 +44,20 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CombinatorApp {
private static final String TEXT = """
It was many and many a year ago,
In a kingdom by the sea,
That a maiden there lived whom you may know
By the name of ANNABEL LEE;
And this maiden she lived with no other thought
Than to love and be loved by me.
I was a child and she was a child,
In this kingdom by the sea;
But we loved with a love that was more than love-
I and my Annabel Lee;
With a love that the winged seraphs of heaven
Coveted her and me.""";
/**
* main.
* @param args args
@@ -69,19 +83,8 @@ public class CombinatorApp {
}
private static String text() {
return
"It was many and many a year ago,\n"
+ "In a kingdom by the sea,\n"
+ "That a maiden there lived whom you may know\n"
+ "By the name of ANNABEL LEE;\n"
+ "And this maiden she lived with no other thought\n"
+ "Than to love and be loved by me.\n"
+ "I was a child and she was a child,\n"
+ "In this kingdom by the sea;\n"
+ "But we loved with a love that was more than love-\n"
+ "I and my Annabel Lee;\n"
+ "With a love that the winged seraphs of heaven\n"
+ "Coveted her and me.";
return TEXT;
}
}
@@ -32,7 +32,10 @@ class FinderTest {
@Test
void contains() {
var example = "the first one \nthe second one \n";
var example = """
the first one
the second one\s
""";
var result = Finder.contains("second").find(example);
assertEquals(1, result.size());
@@ -67,18 +67,19 @@ class FindersTest {
private String text() {
return
"It was many and many a year ago,\n"
+ "In a kingdom by the sea,\n"
+ "That a maiden there lived whom you may know\n"
+ "By the name of ANNABEL LEE;\n"
+ "And this maiden she lived with no other thought\n"
+ "Than to love and be loved by me.\n"
+ "I was a child and she was a child,\n"
+ "In this kingdom by the sea;\n"
+ "But we loved with a love that was more than love-\n"
+ "I and my Annabel Lee;\n"
+ "With a love that the winged seraphs of heaven\n"
+ "Coveted her and me.";
"""
It was many and many a year ago,
In a kingdom by the sea,
That a maiden there lived whom you may know
By the name of ANNABEL LEE;
And this maiden she lived with no other thought
Than to love and be loved by me.
I was a child and she was a child,
In this kingdom by the sea;
But we loved with a love that was more than love-
I and my Annabel Lee;
With a love that the winged seraphs of heaven
Coveted her and me.""";
}
}