Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpreadsheetExpressionFunctionCellTestCase.testGeneralConverterValueTo… #183

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,24 @@
package walkingkooka.spreadsheet.expression.function;

import org.junit.jupiter.api.Test;
import walkingkooka.Cast;
import walkingkooka.collect.list.Lists;
import walkingkooka.convert.ConverterTesting;
import walkingkooka.spreadsheet.SpreadsheetCell;
import walkingkooka.spreadsheet.SpreadsheetFormula;
import walkingkooka.spreadsheet.expression.FakeSpreadsheetExpressionEvaluationContext;
import walkingkooka.spreadsheet.expression.SpreadsheetExpressionEvaluationContext;
import walkingkooka.spreadsheet.expression.SpreadsheetExpressionEvaluationContexts;
import walkingkooka.spreadsheet.meta.SpreadsheetMetadataTesting;
import walkingkooka.spreadsheet.reference.SpreadsheetSelection;
import walkingkooka.text.HasText;
import walkingkooka.tree.expression.ExpressionNumber;

import java.util.Optional;

public abstract class SpreadsheetExpressionFunctionCellTestCase<F extends SpreadsheetExpressionFunctionCell<T>, T> extends SpreadsheetExpressionFunctionTestCase<F, T> {
public abstract class SpreadsheetExpressionFunctionCellTestCase<F extends SpreadsheetExpressionFunctionCell<T>, T> extends SpreadsheetExpressionFunctionTestCase<F, T>
implements ConverterTesting,
SpreadsheetMetadataTesting {

SpreadsheetExpressionFunctionCellTestCase() {
super();
Expand Down Expand Up @@ -83,12 +90,36 @@ public final int minimumParameterCount() {
return 0;
}


@Override
public SpreadsheetExpressionEvaluationContext createContext() {
return SpreadsheetExpressionEvaluationContexts.fake();
}

@Test
public final void testGeneralConverterValueToString() {
Object value = this.valuePresent();
if (value instanceof Optional) {
final Optional<?> optional = Cast.to(value);
value = optional.get();
}

this.convertAndCheck(
METADATA_EN_AU.generalConverter(
SPREADSHEET_FORMATTER_PROVIDER,
SPREADSHEET_PARSER_PROVIDER,
PROVIDER_CONTEXT
),
value,
String.class,
SpreadsheetMetadataTesting.SPREADSHEET_FORMATTER_CONTEXT,
value instanceof HasText ?
HasText.class.cast(value).text() :
value instanceof ExpressionNumber ?
"1." :
"*Something went wrong here*"
);
}

// class............................................................................................................

@Override
Expand Down
Loading