Skip to content

Commit

Permalink
Add tests defining default behaviour of double formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
fkleedorfer committed Sep 16, 2024
1 parent f56f8b4 commit 1cc463a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/test/java/de/atextor/turtle/formatter/TurtleFormatterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,38 @@ public void testSkipFormattingValueOfPredicate() {
assertThat(result.trim()).isEqualTo(modelString);
}

@Test
public void testDoubleFormatDefault() {
final String modelString = """
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://example.com/ns#> .
ex:something ex:decimalProp 0.0000000006241509074460762607776240980930446 ;
ex:doubleProp 6.241509074460762607776240980930446E-10 .""";

final FormattingStyle style = FormattingStyle.builder().build();

final TurtleFormatter formatter = new TurtleFormatter( style );
final String result = formatter.applyToContent( modelString );
assertThat(result.trim()).isEqualTo(modelString);
}

@Test
public void testDoubleFormat() {
final String modelString = """
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://example.com/ns#> .
ex:something ex:decimalProp 0.0000000006241509074460762607776240980930446 ;
ex:doubleProp 6.2415E-10 .""";

final FormattingStyle style = FormattingStyle.builder().skipDoubleFormatting(false).build();

final TurtleFormatter formatter = new TurtleFormatter( style );
final String result = formatter.applyToContent( modelString );
assertThat(result.trim()).isEqualTo(modelString);
}

private Model modelFromString( final String content ) {
final Model model = ModelFactory.createDefaultModel();
final InputStream stream = new ByteArrayInputStream( content.getBytes( StandardCharsets.UTF_8 ) );
Expand Down

0 comments on commit 1cc463a

Please sign in to comment.