From e648827e688373d22b8600e63f825d93ab7f8391 Mon Sep 17 00:00:00 2001 From: zlemihl Date: Mon, 25 Nov 2019 15:02:52 -0600 Subject: [PATCH 1/3] cut long comment in BalancedBracket class and pasted in BalancedBracketsTest --- src/main/BalancedBrackets.java | 22 ++++------------------ src/test/BalancedBracketsTest.java | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/main/BalancedBrackets.java b/src/main/BalancedBrackets.java index 5196fdbd..9fa1d3c3 100644 --- a/src/main/BalancedBrackets.java +++ b/src/main/BalancedBrackets.java @@ -3,24 +3,10 @@ public class BalancedBrackets { /** - * The function BalancedBrackets should return true if and only if - * the input string has a set of "balanced" brackets. - * - * That is, whether it consists entirely of pairs of opening/closing - * brackets (in that order), none of which mis-nest. We consider a bracket - * to be square-brackets: [ or ]. - * - * The string may contain non-bracket characters as well. - * - * These strings have balanced brackets: - * "[LaunchCode]", "Launch[Code]", "[]LaunchCode", "", "[]" - * - * While these do not: - * "[LaunchCode", "Launch]Code[", "[", "][" - * - * @param str - to be validated - * @return true if balanced, false otherwise - */ + * + * @param str - to be validated + * @return true if balanced, false otherwise + */ public static boolean hasBalancedBrackets(String str) { int brackets = 0; for (char ch : str.toCharArray()) { diff --git a/src/test/BalancedBracketsTest.java b/src/test/BalancedBracketsTest.java index 3677ab96..8a4968c6 100644 --- a/src/test/BalancedBracketsTest.java +++ b/src/test/BalancedBracketsTest.java @@ -5,8 +5,24 @@ import static org.junit.Assert.*; public class BalancedBracketsTest { - + /* + * The function BalancedBrackets should return true if and only if + * the input string has a set of "balanced" brackets. + * + * That is, whether it consists entirely of pairs of opening/closing + * brackets (in that order), none of which mis-nest. We consider a bracket + * to be square-brackets: [ or ]. + * + * The string may contain non-bracket characters as well. + * + * These strings have balanced brackets: + * "[LaunchCode]", "Launch[Code]", "[]LaunchCode", "", "[]" + * + * While these do not: + * "[LaunchCode", "Launch]Code[", "[", "][" + */ //TODO: add tests here + @Test public void emptyTest() { assertEquals(true, true); From a7029baa79c9120a7b945a614a61e5be26f56c3f Mon Sep 17 00:00:00 2001 From: zlemihl Date: Mon, 25 Nov 2019 15:19:54 -0600 Subject: [PATCH 2/3] added to the long comment --- src/test/BalancedBracketsTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/BalancedBracketsTest.java b/src/test/BalancedBracketsTest.java index 8a4968c6..0b82d2e5 100644 --- a/src/test/BalancedBracketsTest.java +++ b/src/test/BalancedBracketsTest.java @@ -6,6 +6,19 @@ public class BalancedBracketsTest { /* + * RECOMMENDED: Be agnostic about the code that was written for the class + * that you are testing. Write all the tests that you think you'll need, + * in order to test the BalancedBrackets class FIRST, without looking at + * the code in the BalancedBrackets.java directly; all that you need to + * know in order to write a good test is knowing what the code is supposed + * to do. + * + * Write the tests; run them; and THEN compare the code in the class that + * you were testing with your tests, to find out whether the class, the + * tests, or both need fixing. + * + * ABOUT THE CLASS BalancedBrackets.... + * * The function BalancedBrackets should return true if and only if * the input string has a set of "balanced" brackets. * @@ -20,6 +33,7 @@ public class BalancedBracketsTest { * * While these do not: * "[LaunchCode", "Launch]Code[", "[", "][" + * */ //TODO: add tests here From a4c6a613b89e0a1821955fe5512f97f019c2d1c2 Mon Sep 17 00:00:00 2001 From: zlemihl Date: Mon, 25 Nov 2019 15:21:24 -0600 Subject: [PATCH 3/3] removed test string examples from the long comment --- src/test/BalancedBracketsTest.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/test/BalancedBracketsTest.java b/src/test/BalancedBracketsTest.java index 0b82d2e5..0e6192df 100644 --- a/src/test/BalancedBracketsTest.java +++ b/src/test/BalancedBracketsTest.java @@ -28,12 +28,6 @@ public class BalancedBracketsTest { * * The string may contain non-bracket characters as well. * - * These strings have balanced brackets: - * "[LaunchCode]", "Launch[Code]", "[]LaunchCode", "", "[]" - * - * While these do not: - * "[LaunchCode", "Launch]Code[", "[", "][" - * */ //TODO: add tests here