aboutsummaryrefslogtreecommitdiffstats
path: root/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/VerificationContextTestCase.java
blob: 1df92f647b9dffadc8119feaebd81ba07f4b1047 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.indexinglanguage.expressions;

import com.yahoo.document.DataType;
import org.junit.Test;

import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;

/**
 * @author Simon Thoresen Hult
 */
public class VerificationContextTestCase {

    @Test
    public void requireThatValueCanBeSet() {
        VerificationContext ctx = new VerificationContext();
        DataType val = DataType.STRING;
        ctx.setValueType(val);
        assertSame(val, ctx.getValueType());
    }

    @Test
    public void requireThatVariablesCanBeSet() {
        VerificationContext ctx = new VerificationContext();
        DataType val = DataType.STRING;
        ctx.setVariable("foo", val);
        assertSame(val, ctx.getVariable("foo"));
    }

    @Test
    public void requireThatClearRemovesValue() {
        VerificationContext ctx = new VerificationContext();
        ctx.setValueType(DataType.STRING);
        ctx.clear();
        assertNull(ctx.getValueType());
    }

    @Test
    public void requireThatClearRemovesVariables() {
        VerificationContext ctx = new VerificationContext();
        ctx.setVariable("foo", DataType.STRING);
        ctx.clear();
        assertNull(ctx.getVariable("foo"));
    }
}