[Groovy] convert StringValueTest to Java (IDEA-327339)

GitOrigin-RevId: 535a2f251dcfa2df2b58ee44d6c2f96e6f7cd370
This commit is contained in:
Bas Leijdekkers
2024-04-11 09:51:55 +00:00
committed by intellij-monorepo-bot
parent c773811ac5
commit b686093c55
@@ -1,66 +1,53 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* 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.
*/
package org.jetbrains.plugins.groovy.lang
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.groovy.lang;
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
import org.jetbrains.annotations.Nullable
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral
import org.jetbrains.plugins.groovy.util.TestUtils
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
import junit.framework.TestCase;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
import org.jetbrains.plugins.groovy.util.TestUtils;
/**
* @author Max Medvedev
*/
class StringValueTest extends LightJavaCodeInsightFixtureTestCase {
public class StringValueTest extends LightJavaCodeInsightFixtureTestCase {
@Override
protected String getBasePath() {
"${TestUtils.testDataPath}stringValues/"
return TestUtils.getTestDataPath() + "stringValues/";
}
private void doTest(@Nullable String expected) {
def file = myFixture.configureByFile("${getTestName(false)}.groovy") as GroovyFile
def literal = file.statements[0] as GrLiteral
assertEquals expected, literal.value
GroovyFile file = (GroovyFile)myFixture.configureByFile(getTestName(false) + ".groovy");
GrLiteral literal = (GrLiteral)file.getStatements()[0];
TestCase.assertEquals(expected, literal.getValue());
}
void testString0() {
doTest("fo\nabc \r \u1234 \" \' \" ")
public void testString0() {
doTest("fo\nabc \r ሴ \" ' \" ");
}
void testString1() {
doTest(null)
public void testString1() {
doTest(null);
}
void testString2() {
doTest(null)
public void testString2() {
doTest(null);
}
void testString3() {
doTest("fooabc")
public void testString3() {
doTest("fooabc");
}
void testGString() {
doTest("abc \' \" ")
public void testGString() {
doTest("abc ' \" ");
}
void testSlashString() {
doTest("abc \\a \\n / abc \u1234 \$ \\\$ ")
public void testSlashString() {
doTest("abc \\a \\n / abc ሴ $ \\$ ");
}
void _testDollarSlashString() {
doTest("/abc \\n \\o \u1234 abc \$ / \\\$ /")
public void _testDollarSlashString() {
doTest("/abc \\n \\o ሴ abc $ / \\$ /");
}
}