57 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 58 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 */ 60 package test.java.time.format; 61 62 import java.time.format.*; 63 64 import static org.testng.Assert.assertEquals; 65 66 import org.testng.annotations.Test; 67 68 /** 69 * Test StringLiteralPrinterParser. 70 */ 71 @Test(groups={"implementation"}) 72 public class TestStringLiteralPrinter extends AbstractTestPrinterParser { 73 74 //----------------------------------------------------------------------- 75 public void test_print_emptyCalendrical() throws Exception { 76 buf.append("EXISTING"); 77 getFormatter("hello").printTo(EMPTY_DTA, buf); 78 assertEquals(buf.toString(), "EXISTINGhello"); 79 } 80 81 public void test_print_dateTime() throws Exception { 82 buf.append("EXISTING"); 83 getFormatter("hello").printTo(dta, buf); 84 assertEquals(buf.toString(), "EXISTINGhello"); 85 } 86 87 88 89 90 public void test_print_emptyAppendable() throws Exception { 91 getFormatter("hello").printTo(dta, buf); 92 assertEquals(buf.toString(), "hello"); 93 } 94 95 //----------------------------------------------------------------------- 96 public void test_toString() throws Exception { 97 assertEquals(getFormatter("hello").toString(), "'hello'"); 98 } 99 100 public void test_toString_apos() throws Exception { 101 assertEquals(getFormatter("o'clock").toString(), "'o''clock'"); 102 } 103 104 } | 57 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 58 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 */ 60 package test.java.time.format; 61 62 import java.time.format.*; 63 64 import static org.testng.Assert.assertEquals; 65 66 import org.testng.annotations.Test; 67 68 /** 69 * Test StringLiteralPrinterParser. 70 */ 71 @Test(groups={"implementation"}) 72 public class TestStringLiteralPrinter extends AbstractTestPrinterParser { 73 74 //----------------------------------------------------------------------- 75 public void test_print_emptyCalendrical() throws Exception { 76 buf.append("EXISTING"); 77 getFormatter("hello").formatTo(EMPTY_DTA, buf); 78 assertEquals(buf.toString(), "EXISTINGhello"); 79 } 80 81 public void test_print_dateTime() throws Exception { 82 buf.append("EXISTING"); 83 getFormatter("hello").formatTo(dta, buf); 84 assertEquals(buf.toString(), "EXISTINGhello"); 85 } 86 87 88 89 90 public void test_print_emptyAppendable() throws Exception { 91 getFormatter("hello").formatTo(dta, buf); 92 assertEquals(buf.toString(), "hello"); 93 } 94 95 //----------------------------------------------------------------------- 96 public void test_toString() throws Exception { 97 assertEquals(getFormatter("hello").toString(), "'hello'"); 98 } 99 100 public void test_toString_apos() throws Exception { 101 assertEquals(getFormatter("o'clock").toString(), "'o''clock'"); 102 } 103 104 } |