Skip to content

Commit

Permalink
fn:string, add basic all param test for metaschema-framework#132
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-stein-gsa committed Oct 6, 2024
1 parent b136be3 commit ed31e77
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* SPDX-FileCopyrightText: none
* SPDX-License-Identifier: CC0-1.0
*/

package gov.nist.secauto.metaschema.core.metapath.function.library;

import static gov.nist.secauto.metaschema.core.metapath.TestUtils.string;
import static org.junit.jupiter.api.Assertions.assertEquals;

import gov.nist.secauto.metaschema.core.metapath.ExpressionTestBase;
import gov.nist.secauto.metaschema.core.metapath.ISequence;
import gov.nist.secauto.metaschema.core.metapath.MetapathExpression;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.stream.Stream;

import edu.umd.cs.findbugs.annotations.NonNull;

class FnSubstringTest
extends ExpressionTestBase {
private static Stream<Arguments> provideValues() { // NOPMD - false positive
return Stream.of(
Arguments.of(
ISequence.of(string("ada")),
"substring('metadata', 4, 3)"));
}

@ParameterizedTest
@MethodSource("provideValues")
void testExpression(@NonNull ISequence<?> expected, @NonNull String metapath) {
assertEquals(
expected,
MetapathExpression.compile(metapath)
.evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, newDynamicContext()));
}

}

0 comments on commit ed31e77

Please sign in to comment.