Skip to content

Commit

Permalink
SpreadsheetExpressionFunctionCellTestCase.testGeneralConverterValueTo…
Browse files Browse the repository at this point in the history
…String
  • Loading branch information
mP1 committed Oct 31, 2024
1 parent cceac7d commit 9da0f0c
Showing 1 changed file with 33 additions and 2 deletions.
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

0 comments on commit 9da0f0c

Please sign in to comment.