blob: 99b13b5b4b7670ded9443b05d6f2f1982f8809f3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.indexinglanguage.parser;
import com.yahoo.document.datatypes.*;
import com.yahoo.vespa.indexinglanguage.expressions.Expression;
import com.yahoo.vespa.indexinglanguage.parser.ParseException;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
/**
* @author Simon Thoresen Hult
*/
public class NumberTestCase {
@Test
public void requireThatCorrectNumberTypeIsParsed() throws ParseException {
assertTrue(Expression.fromString("6.9").execute() instanceof DoubleFieldValue);
assertTrue(Expression.fromString("6.9f").execute() instanceof FloatFieldValue);
assertTrue(Expression.fromString("6.9F").execute() instanceof FloatFieldValue);
assertTrue(Expression.fromString("69").execute() instanceof IntegerFieldValue);
assertTrue(Expression.fromString("69l").execute() instanceof LongFieldValue);
assertTrue(Expression.fromString("69L").execute() instanceof LongFieldValue);
assertTrue(Expression.fromString("0x69").execute() instanceof IntegerFieldValue);
assertTrue(Expression.fromString("0x69l").execute() instanceof LongFieldValue);
assertTrue(Expression.fromString("0x69L").execute() instanceof LongFieldValue);
assertTrue(Expression.fromString("'69'").execute() instanceof StringFieldValue);
assertTrue(Expression.fromString("\"69\"").execute() instanceof StringFieldValue);
}
}
|