From e4a1d1b1d789ac98b4328e3de40779d38a243940 Mon Sep 17 00:00:00 2001 From: Alexander Leali Date: Mon, 21 Apr 2025 16:57:17 -0400 Subject: [PATCH 1/6] Tested the sizeOf method with boundary tests --- .../org/assertj/core/util/myArraysTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 assertj-core/src/test/java/org/assertj/core/util/myArraysTest.java diff --git a/assertj-core/src/test/java/org/assertj/core/util/myArraysTest.java b/assertj-core/src/test/java/org/assertj/core/util/myArraysTest.java new file mode 100644 index 00000000000..790d24f5bdc --- /dev/null +++ b/assertj-core/src/test/java/org/assertj/core/util/myArraysTest.java @@ -0,0 +1,25 @@ +package org.assertj.core.util; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class myArraysTest { + + //boundary test + @Test + public void sizeOfTestSmallest(){ assertEquals(0, Arrays.sizeOf(new char[0])); } + + @Test + public void sizeOfTestSecondSmallest(){ assertEquals(1, Arrays.sizeOf(new char[1])); } + + @Test + public void sizeOfTestTypical(){ assertEquals(500, Arrays.sizeOf(new char[500])); } + + @Test + public void sizeOfTestSecondBiggest(){ assertEquals(Integer.MAX_VALUE - 3, Arrays.sizeOf(new char[Integer.MAX_VALUE - 3])); } + + @Test + public void sizeOfTestBiggest(){ assertEquals(Integer.MAX_VALUE - 2, Arrays.sizeOf(new char[Integer.MAX_VALUE - 2])); } + +} From 17f6d3b8c217bd5ec2faaf8ea7c58f1f0f79f89b Mon Sep 17 00:00:00 2001 From: Alexander Leali Date: Mon, 21 Apr 2025 17:16:10 -0400 Subject: [PATCH 2/6] Tested the parse method with equivalent partition testing --- .../assertj/core/util/myDateUtilTests.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 assertj-core/src/test/java/org/assertj/core/util/myDateUtilTests.java diff --git a/assertj-core/src/test/java/org/assertj/core/util/myDateUtilTests.java b/assertj-core/src/test/java/org/assertj/core/util/myDateUtilTests.java new file mode 100644 index 00000000000..aeb456b4c6f --- /dev/null +++ b/assertj-core/src/test/java/org/assertj/core/util/myDateUtilTests.java @@ -0,0 +1,68 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright 2012-2025 the original author or authors. + */ + +package org.assertj.core.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.assertj.core.util.DateUtil.parse; + +import java.text.ParseException; +import java.text.SimpleDateFormat; + +public class myDateUtilTests { + private static SimpleDateFormat dateFormatter; + + private static String[] unparsableDates; + private static String[] parsibleDates; + + @BeforeAll + public static void setupForTests(){ + dateFormatter = new SimpleDateFormat("dd/MM/yyyy"); + unparsableDates = new String[] {"00/00/0000", "1.2/1.1/15.63", "99/99/9999", "gr/eg/milk"}; + parsibleDates = new String[] {"01/01/0001", "01/12/1970", "20/01/2038", "31/12/9999"}; + + } + + //partition equivalence + @Test + public void parseTestExtremeMinimum() throws ParseException { assertThrows(RuntimeException.class, () -> parse(unparsableDates[0])); } + + @Test + public void parseTestFloats() throws ParseException { assertThrows(RuntimeException.class, () -> parse(unparsableDates[1])); } + + @Test + public void parseTest() throws ParseException { assertThrows(RuntimeException.class, () -> parse(unparsableDates[2])); } + + @Test + public void parseTestExtremeMaximum() throws ParseException { assertThrows(RuntimeException.class, () -> parse(unparsableDates[3])); } + + @Test + public void parseTestMinimum() throws ParseException { assertEquals(parse("0001-01-01"), dateFormatter.parse(parsibleDates[0])); } + + @Test + public void parseTestTypical() throws ParseException{ assertEquals(parse("1970-12-01"), dateFormatter.parse(parsibleDates[1])); } + + @Test + public void parseTestEpoch() throws ParseException{ assertEquals(parse("2038-01-20"), dateFormatter.parse(parsibleDates[2])); } + + @Test + public void parseTestMax() throws ParseException{ assertEquals(parse("9999-12-31"), dateFormatter.parse(parsibleDates[3])); } +} + + From 76791b3419653f9182dc7ac3d6d558cd02076b3d Mon Sep 17 00:00:00 2001 From: Alexander Leali Date: Mon, 21 Apr 2025 18:17:38 -0400 Subject: [PATCH 3/6] tested the isNullOrEmpty method with equivalence partitioning --- .../org/assertj/core/util/myStringsTests.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java diff --git a/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java b/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java new file mode 100644 index 00000000000..27ee87506be --- /dev/null +++ b/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java @@ -0,0 +1,62 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright 2012-2025 the original author or authors. + */ + +package org.assertj.core.util; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvFileSource; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; + +class myStringsTests { + + private static String[] escapeCharacters; + private static String[] typicalStrings; + + @BeforeAll + static public void setUp(){ + escapeCharacters = new String[] {"\n", "\t", "\b", "\'", "\""}; + typicalStrings = new String[] {"Writing strings is so much fun", Character.toString(0)}; + + } + + @Test + public void isNullOrEmptyTestTypical(){ assertEquals(false, Strings.isNullOrEmpty(typicalStrings[0])); } + + @Test + public void isNullOrEmptyTestNumber(){ assertEquals(false, Strings.isNullOrEmpty(typicalStrings[1])); } + + @Test + public void isNullOrEmptyTestNewline(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[0])); } + + @Test + public void isNullOrEmptyTestTab(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[1])); } + + @Test + public void isNullOrEmptyTestBackspace(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[2])); } + + @Test + public void isNullOrEmptyTestApostropphe(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[3])); } + + @Test + public void isNullOrEmptyTestQuote(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[4]));} +} From 5a91d77b3ad8eae027d58af7e5ea2f53ec8ab6ed Mon Sep 17 00:00:00 2001 From: Alexander Leali Date: Mon, 21 Apr 2025 18:28:35 -0400 Subject: [PATCH 4/6] tested the quote method using equivalence partitions --- .../org/assertj/core/util/myStringsTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java b/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java index 27ee87506be..f3c6add6795 100644 --- a/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java +++ b/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java @@ -37,6 +37,7 @@ static public void setUp(){ escapeCharacters = new String[] {"\n", "\t", "\b", "\'", "\""}; typicalStrings = new String[] {"Writing strings is so much fun", Character.toString(0)}; + } @Test @@ -59,4 +60,20 @@ static public void setUp(){ @Test public void isNullOrEmptyTestQuote(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[4]));} + + @Test + public void quotesAroundObjectsTestBool(){ assertEquals(true, Strings.quote(true)); } + + @Test + public void quotesAroundObjectsTestShort(){ assertEquals(Short.MIN_VALUE, Strings.quote(Short.MIN_VALUE)); } + + @Test + public void quotesAroundObjectsTestDoubleMin() { assertEquals(Double.MIN_VALUE, Strings.quote(Double.MIN_VALUE)); } + + @Test + public void quotesAroundObjectsTestDoubleMax(){ assertEquals(Double.MAX_VALUE, Strings.quote(Double.MAX_VALUE)); } + + @Test + public void quotesAroundObjectsEmptyString(){ assertEquals("''", Strings.quote("")); } } + From e66da30ab513c3db953790586be524862e41fa0d Mon Sep 17 00:00:00 2001 From: Alexander Leali Date: Mon, 21 Apr 2025 19:22:08 -0400 Subject: [PATCH 5/6] tested the escapePercent method with partition equivalence --- .../org/assertj/core/util/myStringsTests.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java b/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java index f3c6add6795..2eacf1bcab8 100644 --- a/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java +++ b/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java @@ -31,13 +31,13 @@ class myStringsTests { private static String[] escapeCharacters; private static String[] typicalStrings; + private static String[] stringsForPercentEscape; @BeforeAll static public void setUp(){ escapeCharacters = new String[] {"\n", "\t", "\b", "\'", "\""}; typicalStrings = new String[] {"Writing strings is so much fun", Character.toString(0)}; - - + stringsForPercentEscape = new String[] {"This is a string", "%", "This sentence %has a percent in it", "%This %sentence %has %lots of percents %in it", "╫╦£æ₧", "%╫%╦£æ%₧", "\b%Backspaced character"}; } @Test @@ -75,5 +75,29 @@ static public void setUp(){ @Test public void quotesAroundObjectsEmptyString(){ assertEquals("''", Strings.quote("")); } + + @Test + public void escapePercentTestNull(){ assertEquals(null, Strings.escapePercent(null)); } + + @Test + public void escapePercentTestNoPercent(){ assertEquals("This is a string", Strings.escapePercent(stringsForPercentEscape[0])); } + + @Test + public void escapePercentTestSinglePercent(){ assertEquals("%%", Strings.escapePercent(stringsForPercentEscape[1])); } + + @Test + public void escapePercentTestPercentInString(){ assertEquals("This sentence %%has a percent in it", Strings.escapePercent(stringsForPercentEscape[2])); } + + @Test + public void escapePercentTestPercentsInString(){ assertEquals("%%This %%sentence %%has %%lots of percents %%in it", Strings.escapePercent(stringsForPercentEscape[3])); } + + @Test + public void escapePercentTestSpecialString(){ assertEquals("╫╦£æ₧", Strings.escapePercent(stringsForPercentEscape[4])); } + + @Test + public void escapePercentTestSpecialStringWithPercents(){ assertEquals("%%╫%%╦£æ%%₧", Strings.escapePercent(stringsForPercentEscape[5])); } + + @Test + public void escapePercentTestEscapeSequenceString(){ assertEquals("\b%%Backspaced character", Strings.escapePercent(stringsForPercentEscape[6])); } } From b199887188133eaf05c663e3bae7a6108555d1a6 Mon Sep 17 00:00:00 2001 From: Alexander Leali Date: Fri, 25 Apr 2025 20:02:11 -0400 Subject: [PATCH 6/6] removed unused test cases since it was one test over the required 10 --- .../org/assertj/core/util/myStringsTests.java | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java b/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java index 2eacf1bcab8..39a197d9e23 100644 --- a/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java +++ b/assertj-core/src/test/java/org/assertj/core/util/myStringsTests.java @@ -40,27 +40,6 @@ static public void setUp(){ stringsForPercentEscape = new String[] {"This is a string", "%", "This sentence %has a percent in it", "%This %sentence %has %lots of percents %in it", "╫╦£æ₧", "%╫%╦£æ%₧", "\b%Backspaced character"}; } - @Test - public void isNullOrEmptyTestTypical(){ assertEquals(false, Strings.isNullOrEmpty(typicalStrings[0])); } - - @Test - public void isNullOrEmptyTestNumber(){ assertEquals(false, Strings.isNullOrEmpty(typicalStrings[1])); } - - @Test - public void isNullOrEmptyTestNewline(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[0])); } - - @Test - public void isNullOrEmptyTestTab(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[1])); } - - @Test - public void isNullOrEmptyTestBackspace(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[2])); } - - @Test - public void isNullOrEmptyTestApostropphe(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[3])); } - - @Test - public void isNullOrEmptyTestQuote(){ assertEquals(false, Strings.isNullOrEmpty(escapeCharacters[4]));} - @Test public void quotesAroundObjectsTestBool(){ assertEquals(true, Strings.quote(true)); }