From df48850bfe1b42c26d7b65f5b342762a68fdf388 Mon Sep 17 00:00:00 2001 From: John Bergqvist Date: Fri, 13 Apr 2018 11:08:05 +0100 Subject: [PATCH] Add tests for client.ai.utils.AiSpellParser from Diffblue Deeptest --- pom.xml | 5 + .../client/ai/utils/AiSpellParserTest.java | 172 ++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 symphony-client/src/test/java/org/symphonyoss/client/ai/utils/AiSpellParserTest.java diff --git a/pom.xml b/pom.xml index 251f41e0..f23adf3b 100644 --- a/pom.xml +++ b/pom.xml @@ -150,6 +150,11 @@ jackson-jaxrs-json-provider ${jackson.version} + + com.diffblue + deeptestutils + 1.1.0 + diff --git a/symphony-client/src/test/java/org/symphonyoss/client/ai/utils/AiSpellParserTest.java b/symphony-client/src/test/java/org/symphonyoss/client/ai/utils/AiSpellParserTest.java new file mode 100644 index 00000000..1105aa1f --- /dev/null +++ b/symphony-client/src/test/java/org/symphonyoss/client/ai/utils/AiSpellParserTest.java @@ -0,0 +1,172 @@ +/* + * + * + * Copyright 2018 Diffblue Limited + * + * Licensed to The Symphony Software Foundation (SSF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The SSF licenses this file + * to you 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. + * + */ + +package org.symphonyoss.client.ai.utils; +import org.junit.Assert; +import org.junit.rules.ExpectedException; +import org.junit.Test; +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import com.diffblue.deeptestutils.CompareWithFieldList; +import com.diffblue.deeptestutils.Reflector; +@org.junit.runner.RunWith(org.powermock.modules.junit4.PowerMockRunner.class) +public class AiSpellParserTest { + @org.junit.Rule + public ExpectedException thrown = ExpectedException.none(); + /* testedClasses: AiSpellParser */ + + /* + * Test generated by Diffblue Deeptest. + * This test case covers: + * conditional line 171 branch to line 172 + * org/symphonyoss/client/ai/utils/AiSpellParser.java:179: loop: 1 iterations + * iteration 1 + * conditional line 180 branch to line 180 + * conditional line 180 branch to line 179 + * conditional line 183 branch to line 183 + */ + + @org.junit.Test + public void org_symphonyoss_client_ai_utils_AiSpellParser_isCloseTo_000_a2a15613a4edd99f() throws Throwable { + + boolean retval; + { + /* Arrange */ + String input1 = "?"; + String input2 = ""; + double closenessFactor = 0.0; + + /* Act */ + Class c = Reflector.forName("org.symphonyoss.client.ai.utils.AiSpellParser"); + Method m = c.getDeclaredMethod("isCloseTo", Reflector.forName("java.lang.String"), Reflector.forName("java.lang.String"), Reflector.forName("double")); + m.setAccessible(true); + retval = (boolean) m.invoke(null, input1, input2, closenessFactor); + } + { + /* Assert result */ + Assert.assertEquals(false, retval); + } + } + + /* + * Test generated by Diffblue Deeptest. + * This test case covers: + * conditional line 171 branch to line 172 + * org/symphonyoss/client/ai/utils/AiSpellParser.java:179: loop: 1 iterations + * iteration 1 + * conditional line 180 branch to line 180 + * conditional line 180 branch to line 179 + * conditional line 183 branch to line 183 + */ + + @org.junit.Test + public void org_symphonyoss_client_ai_utils_AiSpellParser_isCloseTo_001_2e7b54f146d8f0cf() throws Throwable { + + boolean retval; + { + /* Arrange */ + String input1 = "?"; + String input2 = ""; + double closenessFactor = -0x1.0000000000001p+1 /* -2.0 */; + + /* Act */ + Class c = Reflector.forName("org.symphonyoss.client.ai.utils.AiSpellParser"); + Method m = c.getDeclaredMethod("isCloseTo", Reflector.forName("java.lang.String"), Reflector.forName("java.lang.String"), Reflector.forName("double")); + m.setAccessible(true); + retval = (boolean) m.invoke(null, input1, input2, closenessFactor); + } + { + /* Assert result */ + Assert.assertEquals(true, retval); + } + } + + /* + * Test generated by Diffblue Deeptest. + * This test case covers: + * conditional line 171 branch to line 175 + * org/symphonyoss/client/ai/utils/AiSpellParser.java:179: loop: 1 iterations + * iteration 1 + * conditional line 180 branch to line 180 + * conditional line 180 branch to line 179 + * conditional line 183 branch to line 183 + */ + + @org.junit.Test + public void org_symphonyoss_client_ai_utils_AiSpellParser_isCloseTo_002_71975b80a4f1f106() throws Throwable { + + boolean retval; + { + /* Arrange */ + String input1 = ""; + String input2 = "?"; + double closenessFactor = -0x1.0000000000001p+1 /* -2.0 */; + + /* Act */ + Class c = Reflector.forName("org.symphonyoss.client.ai.utils.AiSpellParser"); + Method m = c.getDeclaredMethod("isCloseTo", Reflector.forName("java.lang.String"), Reflector.forName("java.lang.String"), Reflector.forName("double")); + m.setAccessible(true); + retval = (boolean) m.invoke(null, input1, input2, closenessFactor); + } + { + /* Assert result */ + Assert.assertEquals(true, retval); + } + } + + /* + * Test generated by Diffblue Deeptest. + * This test case covers: + * conditional line 171 branch to line 175 + * org/symphonyoss/client/ai/utils/AiSpellParser.java:179: loop: 1 iterations + * iteration 1 + * conditional line 180 branch to line 180 + * conditional line 180 branch to line 181 + * conditional line 183 branch to line 183 + */ + + @org.junit.Test + public void org_symphonyoss_client_ai_utils_AiSpellParser_isCloseTo_003_5933843219c118fd() throws Throwable { + + boolean retval; + { + /* Arrange */ + String input1 = "?"; + String input2 = "?"; + double closenessFactor = -0x1.0000000000001p+8 /* -256.0 */; + + /* Act */ + Class c = Reflector.forName("org.symphonyoss.client.ai.utils.AiSpellParser"); + Method m = c.getDeclaredMethod("isCloseTo", Reflector.forName("java.lang.String"), Reflector.forName("java.lang.String"), Reflector.forName("double")); + m.setAccessible(true); + retval = (boolean) m.invoke(null, input1, input2, closenessFactor); + } + { + /* Assert result */ + Assert.assertEquals(true, retval); + } + } +}