Search in sources :

Example 1 with IResult

use of com.ichi2.libanki.template.Tokenizer.IResult in project Anki-Android by ankidroid.

the class TokenizerTest method test_next_token.

private void test_next_token(@NonNull String template, @NonNull Tokenizer.TokenKind token, @NonNull String field_name, @NonNull String remaining) {
    IResult expected = new IResult(new Tokenizer.Token(token, field_name), remaining);
    assertThat(next_token(template, true), is(expected));
    assertThat(next_token(template, false), is(expected));
    IResult legacy_expected = expected.new_to_legacy();
    String legacy_template = new_to_legacy(template);
    assertThat(next_token(legacy_template, true), is(legacy_expected));
}
Also used : Token(com.ichi2.libanki.template.Tokenizer.Token) IResult(com.ichi2.libanki.template.Tokenizer.IResult)

Example 2 with IResult

use of com.ichi2.libanki.template.Tokenizer.IResult in project Anki-Android by ankidroid.

the class TokenizerTest method test_text_token.

private void test_text_token(@NonNull String template, @NonNull IResult expected) {
    assertThat(text_token(template, false), is(expected));
    assertThat(text_token(template, true), is(expected));
    String legacy_template = new_to_legacy(template);
    IResult legacy_expected = expected.new_to_legacy();
    assertThat(text_token(legacy_template, true), is(legacy_expected));
// No test for legacy_template without legacy interpretation.
}
Also used : IResult(com.ichi2.libanki.template.Tokenizer.IResult)

Example 3 with IResult

use of com.ichi2.libanki.template.Tokenizer.IResult in project Anki-Android by ankidroid.

the class TokenizerTest method test_handlebar_token.

private void test_handlebar_token(@NonNull String template, @NonNull Tokenizer.TokenKind token, @NonNull String field_name, @NonNull String remaining) {
    IResult expected = new IResult(new Tokenizer.Token(token, field_name), remaining);
    assertThat(new_handlebar_token(template), is(expected));
    assertThat(handlebar_token(template, true), is(expected));
    assertThat(handlebar_token(template, false), is(expected));
    String legacy_template = new_to_legacy(template);
    IResult legacy_expected = expected.new_to_legacy();
    assertThat(legacy_handlebar_token(legacy_template), is(legacy_expected));
    assertThat(handlebar_token(legacy_template, true), is(legacy_expected));
    assertThat(handlebar_token(legacy_template, false), nullValue());
}
Also used : Token(com.ichi2.libanki.template.Tokenizer.Token) IResult(com.ichi2.libanki.template.Tokenizer.IResult)

Aggregations

IResult (com.ichi2.libanki.template.Tokenizer.IResult)3 Token (com.ichi2.libanki.template.Tokenizer.Token)2