aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/grouping/vespa/IntegerEncoderTestCase.java
blob: 3b48ae35fcf2b4e1875dad55297acd27a64278bb (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.vespa;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

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

    @Test
    public void requireThatIntEncoderWorksAsExpected() {
        assertEncode("A", 0);
        assertEncode("BC", 1);
        assertEncode("CBI", 12);
        assertEncode("CPG", 123);
        assertEncode("DJKE", 1234);
        assertEncode("EGAHC", 12345);
        assertEncode("FDMEIA", 123456);
        assertEncode("GCFKNAO", 1234567);
        assertEncode("HBHIMCJM", 12345678);
        assertEncode("HOLHJKCK", 123456789);
        assertEncode("IJDCMAFKE", 1234567890);
        assertEncode("IIKKEBPOF", -1163005939);
        assertEncode("IECKEIKID", -559039810);
    }

    private static void assertEncode(String expected, int toEncode) {
        IntegerEncoder actual = new IntegerEncoder();
        actual.append(toEncode);
        assertEquals(expected, actual.toString());
    }
}