Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitin Dahyabhai2020-03-23 03:08:13 +0000
committerNitin Dahyabhai2020-03-23 03:08:13 +0000
commit24806a1eba48cee2cad5b4f7af41fca47553a6f2 (patch)
treeee0008d0310ced70b3fa24c36ccea7a61b57a4ba
parent1c6e57e97ef0a6bb5825416cda24ff32dbe2a935 (diff)
downloadwebtools.sourceediting-24806a1eba48cee2cad5b4f7af41fca47553a6f2.tar.gz
webtools.sourceediting-24806a1eba48cee2cad5b4f7af41fca47553a6f2.tar.xz
webtools.sourceediting-24806a1eba48cee2cad5b4f7af41fca47553a6f2.zip
[nobug] add tests for StringUtils
-rw-r--r--core/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/util/TestStringUtils.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/core/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/util/TestStringUtils.java b/core/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/util/TestStringUtils.java
new file mode 100644
index 0000000000..2cd9b18eb6
--- /dev/null
+++ b/core/tests/org.eclipse.wst.sse.core.tests/src/org/eclipse/wst/sse/core/tests/util/TestStringUtils.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2020 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *
+ *******************************************************************************/
+
+package org.eclipse.wst.sse.core.tests.util;
+
+import org.eclipse.wst.sse.core.utils.StringUtils;
+
+import junit.framework.TestCase;
+
+public class TestStringUtils extends TestCase {
+ public void testFirstLine() {
+ assertEquals("a", StringUtils.firstLine("a", 5, true));
+ assertEquals("a", StringUtils.firstLine("a", 5, false));
+ assertEquals("abcde...", StringUtils.firstLine("abcdefgh", 5, true));
+ assertEquals("abcde", StringUtils.firstLine("abcdefgh", 5, false));
+ assertEquals("abcde...", StringUtils.firstLine("abcdefgh\n", 5, true));
+ assertEquals("abcde", StringUtils.firstLine("abcdefgh\n", 5, false));
+ assertEquals("abcde...", StringUtils.firstLine("abcde\nfghij", 15, true));
+ assertEquals("abcde", StringUtils.firstLine("abcde\nfghij", 15, false));
+ assertEquals("abcde...", StringUtils.firstLine("\nabcde\nfghij", 15, true));
+ assertEquals("abcde", StringUtils.firstLine("\nabcde\nfghij", 15, false));
+ assertEquals("abcde...", StringUtils.firstLine("\nabcdefghij\n", 5, true));
+ assertEquals("abcde", StringUtils.firstLine("\nabcdefghij\n", 5, false));
+ }
+}

Back to the top