Esempio n. 1
0
    def test(self):
        trie = Trie()
        map = ResultMap()

        trie.insert("math", map.add("Math", "namespaceMath.html", flags=ResultFlag.NAMESPACE))
        index = map.add("Math::Vector", "classMath_1_1Vector.html", flags=ResultFlag.CLASS)
        trie.insert("math::vector", index)
        trie.insert("vector", index)
        index = map.add("Math::Range", "classMath_1_1Range.html", flags=ResultFlag.CLASS)
        trie.insert("math::range", index)
        trie.insert("range", index)

        serialized = serialize_search_data(trie, map, 3)
        self.compare(serialized, """
3 symbols
math [0]
|   ::vector [1]
|     range [2]
vector [1]
range [2]
0: Math [type=NAMESPACE] -> namespaceMath.html
1: ::Vector [prefix=0[:0], type=CLASS] -> classMath_1_1Vector.html
2: ::Range [prefix=0[:0], type=CLASS] -> classMath_1_1Range.html
""")
        self.assertEqual(len(serialized), 241)
Esempio n. 2
0
    def test_single(self):
        map = ResultMap()
        self.assertEqual(map.add("Magnum", "namespaceMagnum.html", suffix_length=11, flags=ResultFlag.NAMESPACE), 0)

        serialized = map.serialize()
        self.compare(serialized, """
0: Magnum [suffix_length=11, type=NAMESPACE] -> namespaceMagnum.html
""")
        self.assertEqual(len(serialized), 36)
Esempio n. 3
0
    def test_multiple(self):
        map = ResultMap()

        self.assertEqual(
            map.add("Math", "namespaceMath.html", flags=ResultFlag.NAMESPACE),
            0)
        self.assertEqual(
            map.add("Math::Vector",
                    "classMath_1_1Vector.html",
                    flags=ResultFlag.CLASS), 1)
        self.assertEqual(
            map.add("Math::Range",
                    "classMath_1_1Range.html",
                    flags=ResultFlag.CLASS), 2)
        self.assertEqual(
            map.add("Math::min()",
                    "namespaceMath.html#abcdef2875",
                    flags=ResultFlag.FUNC), 3)
        self.assertEqual(
            map.add("Math::max(int, int)",
                    "namespaceMath.html#abcdef1234",
                    suffix_length=8,
                    flags=ResultFlag.FUNC | ResultFlag.DEPRECATED
                    | ResultFlag.DELETED), 4)
        self.assertEqual(map.add("Rectangle", "", alias=2), 5)
        self.assertEqual(
            map.add("Rectangle::Rect()", "", suffix_length=2, alias=2), 6)

        serialized = map.serialize()
        self.compare(
            serialized, """
0: Math [type=NAMESPACE] -> namespaceMath.html
1: ::Vector [prefix=0[:0], type=CLASS] -> classMath_1_1Vector.html
2: ::Range [prefix=0[:0], type=CLASS] -> classMath_1_1Range.html
3: ::min() [prefix=0[:18], type=FUNC] -> #abcdef2875
4: ::max(int, int) [prefix=0[:18], suffix_length=8, deprecated, deleted, type=FUNC] -> #abcdef1234
5: Rectangle [alias=2] ->
6: ::Rect() [alias=2, prefix=5[:0], suffix_length=2] ->
""")
        self.assertEqual(len(serialized), 203)
Esempio n. 4
0
    def test_empty(self):
        map = ResultMap()

        serialized = map.serialize()
        self.compare(serialized, "")
        self.assertEqual(len(serialized), 4)
Esempio n. 5
0
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             '..'))

from dox2html5 import Trie, ResultMap, ResultFlag, serialize_search_data

basedir = pathlib.Path(os.path.dirname(
    os.path.realpath(__file__))) / 'js-test-data'

with open(basedir / 'short.bin', 'wb') as f:
    f.write(b'')
with open(basedir / 'wrong-magic.bin', 'wb') as f:
    f.write(b'MOS\0                ')
with open(basedir / 'wrong-version.bin', 'wb') as f:
    f.write(b'MCS\1                ')
with open(basedir / 'empty.bin', 'wb') as f:
    f.write(serialize_search_data(Trie(), ResultMap(), 0))

trie = Trie()
map = ResultMap()

trie.insert("math",
            map.add("Math", "namespaceMath.html", flags=ResultFlag.NAMESPACE))
index = map.add("Math::min(int, int)",
                "namespaceMath.html#min",
                suffix_length=8,
                flags=ResultFlag.FUNC)
trie.insert("math::min()", index, lookahead_barriers=[4])
trie.insert("min()", index)
index = map.add("Math::Vector",
                "classMath_1_1Vector.html",
                flags=ResultFlag.CLASS | ResultFlag.DEPRECATED)
Esempio n. 6
0
                3,
                lookahead_barriers=[] if args.no_lookahead_barriers else [6])
    trie.insert("range", 4)
    trie.insert("range::min",
                5,
                lookahead_barriers=[] if args.no_lookahead_barriers else [5])
    trie.insert("min", 3)
    trie.insert("min", 5)
    trie.insert("min", 6)

    if args.unicode:
        trie = Trie()
        trie.insert("hýždě", 13)
        trie.insert("hárá", 42)

    map = ResultMap()
    map.add("Magnum", "namespaceMagnum.html", flags=ResultFlag.NAMESPACE)
    map.add("Magnum::Math",
            "namespaceMagnum_1_1Math.html",
            flags=ResultFlag.NAMESPACE)
    map.add("Magnum::Math::Vector",
            "classMagnum_1_1Math_1_1Vector.html",
            flags=ResultFlag.CLASS)
    map.add(
        "Magnum::Math::Vector::min()",
        "classMagnum_1_1Math_1_1Vector.html#af029f9f7810201f0bd8d9580af273bde",
        flags=ResultFlag.FUNC)
    map.add("Magnum::Math::Range",
            "classMagnum_1_1Math_1_1Range.html",
            flags=ResultFlag.CLASS)
    map.add(