Naming convention macros should produce empty result on empty string 2

This commit is contained in:
Alexander Zolotov
2016-04-26 21:38:52 +03:00
parent 375b8a2b44
commit 67d7150d7e
2 changed files with 6 additions and 9 deletions
@@ -41,7 +41,7 @@ class NamingConventionMacrosTest extends TestCase {
assert "a_b_c_d_e_f_g" == snakeCase("a-b.c/d|e*f+g")
assert "a_b" == snakeCase("a--b")
assert "foo_bar" == snakeCase("FOO BAR")
assert "" == snakeCase("0")
assert "" == snakeCase("")
}
public void "test lowercase and dash"() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -43,16 +43,13 @@ public class ConvertToCamelCaseMacro extends MacroBase {
@Override
protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) {
final String text = getTextResult(params, context, true);
if (text != null) {
return convertString(text);
}
return null;
return text != null ? convertString(text) : null;
}
@SuppressWarnings("StringToUpperCaseOrToLowerCaseWithoutLocale")
@Nullable
@NotNull
@VisibleForTesting
public Result convertString(String text) {
public Result convertString(@NotNull String text) {
final String[] strings = splitWords(text);
if (strings.length > 0) {
final StringBuilder buf = new StringBuilder();
@@ -65,7 +62,7 @@ public class ConvertToCamelCaseMacro extends MacroBase {
}
return new TextResult(buf.toString());
}
return null;
return new TextResult("");
}
@NotNull