File: test_state.py

package info (click to toggle)
python-datrie 0.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,036 kB
  • sloc: ansic: 3,794; python: 756; sh: 13; makefile: 9
file content (26 lines) | stat: -rw-r--r-- 504 bytes parent folder | download | duplicates (5)
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
# -*- coding: utf-8 -*-

from __future__ import absolute_import, unicode_literals

import datrie


def _trie():
    trie = datrie.Trie(ranges=[(chr(0), chr(127))])
    trie['f'] = 1
    trie['fo'] = 2
    trie['fa'] = 3
    trie['faur'] = 4
    trie['fauxiiiip'] = 5
    trie['fauzox'] = 10
    trie['fauzoy'] = 20
    return trie


def test_trie_state():
    trie = _trie()
    state = datrie.State(trie)
    state.walk('f')
    assert state.data() == 1
    state.walk('o')
    assert state.data() == 2