From 1ab880898f1d542fd2d450138a4517624a331723 Mon Sep 17 00:00:00 2001 From: Manuel Bl Date: Fri, 31 May 2024 17:12:30 +0200 Subject: [PATCH] Increase coverage --- .../qrbill/canvas/FontMetricsTest.java | 17 +++++++++++++++++ .../codecrete/qrbill/generator/BillTest.java | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/generator/src/test/java/net/codecrete/qrbill/canvas/FontMetricsTest.java b/generator/src/test/java/net/codecrete/qrbill/canvas/FontMetricsTest.java index 217fe6e..7ac3f47 100644 --- a/generator/src/test/java/net/codecrete/qrbill/canvas/FontMetricsTest.java +++ b/generator/src/test/java/net/codecrete/qrbill/canvas/FontMetricsTest.java @@ -18,6 +18,7 @@ * Unit tests for {@link FontMetrics} class */ @DisplayName("Font metrics / line wrapping") +@SuppressWarnings("java:S5976") class FontMetricsTest { private FontMetrics fontMetrics; @@ -118,4 +119,20 @@ void newlines_hasWidth0() { assertEquals(0, fontMetrics.getTextWidth("\n", 10, false)); assertEquals(0, fontMetrics.getTextWidth("\r", 10, false)); } + + @Test + void fontFamilyWithQuotes_works() { + FontMetrics metrics = new FontMetrics("\"Liberation Sans\""); + assertEquals(5.70089, metrics.getTextWidth("ďīŊ", 10, false), 0.0001); + } + + @Test + void latinExtendedBChars_textWidthWork() { + assertEquals(1.76389, fontMetrics.getTextWidth("ș", 10, false), 0.0001); + } + + @Test + void euroSign_textWidthWork() { + assertEquals(2.62467, fontMetrics.getTextWidth("€", 10, false), 0.0001); + } } diff --git a/generator/src/test/java/net/codecrete/qrbill/generator/BillTest.java b/generator/src/test/java/net/codecrete/qrbill/generator/BillTest.java index 253bbe2..4e3deed 100644 --- a/generator/src/test/java/net/codecrete/qrbill/generator/BillTest.java +++ b/generator/src/test/java/net/codecrete/qrbill/generator/BillTest.java @@ -116,6 +116,14 @@ void setReference() { assertEquals(Bill.REFERENCE_TYPE_CRED_REF, bill.getReferenceType()); } + @Test + void setReferenceToEmpty() { + Bill bill = new Bill(); + bill.setReference(""); + assertEquals("", bill.getReference()); + assertEquals(Bill.REFERENCE_TYPE_NO_REF, bill.getReferenceType()); + } + @Test void createCreditorReference() { Bill bill = new Bill(); @@ -184,6 +192,7 @@ void setCharacterSet() { assertEquals(SPSCharacterSet.EXTENDED_LATIN, bill.getCharacterSet()); } + @SuppressWarnings({"EqualsWithItself", "AssertBetweenInconvertibleTypes"}) @Test void testEqualsTrivial() { Bill bill = new Bill();