# open htmlcov/index.html in your browser
cd documentation
- node ./node_modules/istanbul/lib/cli.js cover test_doxygen/test-search.js
+ node ./node_modules/istanbul/lib/cli.js cover test/test-search.js
# open coverage/lcov-report/index.html in your browser
cd plugins
--- /dev/null
+#
+# This file is part of m.css.
+#
+# Copyright © 2017, 2018, 2019 Vladimír Vondruš <mosra@centrum.cz>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
--- /dev/null
+#
+# This file is part of m.css.
+#
+# Copyright © 2017, 2018, 2019 Vladimír Vondruš <mosra@centrum.cz>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+import enum
+
+from _search import CssClass
+
+# Taken from doxygen.py, with stuff that's unused in the generic tests removed.
+# It's C++-specific but the implementation doesn't really care, actually ;)
+
+class EntryType(enum.Enum):
+ # Order must match the search_type_map below; first value is reserved for
+ # ResultFlag.ALIAS
+ PAGE = 1
+ NAMESPACE = 2
+ CLASS = 3
+ FUNC = 4
+
+# Order must match the EntryType above
+search_type_map = [
+ (CssClass.SUCCESS, "page"),
+ (CssClass.PRIMARY, "namespace"),
+ (CssClass.PRIMARY, "class"),
+ (CssClass.INFO, "func")
+]
-O+!-w2LOZt004pl003kG000310RR921ONaj009U904M+f4gdgd009&L0BHdL0{{R4AOHX<00ATb04M+fDgXd(00A%n0BHaLHUI!^00BGz06GBy0suk)fI0vHNB{tG00B?{0B-;RRsaBW00CS80Am0FVgLYT0RRO600C|Q04V?gasU7*00DRa0B!&QegFVz00D#m0BryPiU0sQ0RaR6kN|)>00EW&0A&CHo&W%600E=`0B!&QssI3C00SBT0BvXh0Cund0CE5Uwg3P+0RaF2!~lRg00GJX0B8UK(f|N-0{{U40{{g800G_r04V?g<^TXF00Ha(0B!&R*Z=@w@&Ev70RRU8009C40A&CH1_1zU009gE0A~OJ5&-~i0RadA7y$rb00ABW0CWHWCIJ9r00OE20AVZv0A&FH1^@s7JOKb@00BS&0A~OJMgag}00B$^0B`^SQUL&B00CG50CfNa_y7QHXaE3qG64W`UI74eC;$K;KL7x!R{#J?djJ5bkpKWlvj70C$p8Ql<p2Nx@Bjb_{r~^~O<{Cs0B&JzWpi+0V`WWYbZ9PUbZu+^01^l~I&EogC~0nVEFfuabSVHMZE0=*0025VR%K&!Z*l-*Y+-YAO<{CsUol@XR%K&!Z*neZbZu+`02l^3I&EogC@COgZ*FsR03&T_ZU6uPIyzEeZf9ixV{Bn_b4_7%XkRg3F;Zb}XJsyEbZu+|02c;2I&EogC@COgZ*FsR03&T_Zct%oWgx=4AX9Z>aA9X<0CRO>aA9X<E@*UZYy<#OWn*+<Zf9&|1ONvB00KHXQe|UwC@BIS0U`n`0WbkI0XqRe14jc&1x^K00ayTB0Av7XaA9X<ZeeX@b8ul}WoL44b#P;BVRLhHbaHiLbaifNZ*FvXaAjm=W@Kq{W@&6?W_503WMyV)Ze?X|b!}yCb!{MaVQh9`asU7T
\ No newline at end of file
+O+!-w2LOZt004pl003kG000310RR921ONaj009U904M+f4gdgd009&L0BHdL0{{R4AOHX<00ATb04M+fDgXd(00A%n0BHaLHUI!^00BGz06GBy0suk)fI0vHNB{tG00B?{0B-;RRsaBW00CS80Am0FVgLYT0RRO600C|Q04V?gasU7*00DRa0B!&QegFVz00D#m0BryPiU0sQ0RaR6kN|)>00EW&0A&CHo&W%600E=`0B!&QssI3C00SBT0BvXh0Cund0CE5Uwg3P+0RaF2!~lRg00GJX0B8UK(f|N-0{{U40{{g800G_r04V?g<^TXF00Ha(0B!&R*Z=@w@&Ev70RRU8009C40A&CH1_1zU009gE0A~OJ5&-~i0RadA7y$rb00ABW0CWHWCIJ9r00OE20AVZv0A&FH1^@s7JOKb@00BS&0A~OJMgag}00B$^0B`^SQUL&B00CG50CfNa_y7QHXaE3qG64W`UI74eC;$K;KL7wpR{#JydjJ4QkpKWVvj6~1$p8Ql<p2Nx@Bjb_{r~^~O<{Cs0B&JzWpi+0V`WWYbZ9PUbZu+^01^l~I&EogC~0nVEFfuabSVHMZE0=*0025VR%K&!Z*l-*Y+-YAO<{CsUol@XR%K&!Z*neZbZu+`02l^3I&EogC@COgZ*FsR03&T_ZU6uPIyzEeZf9ixV{Bn_b4_7%XkRg3F;Zb}XJsyEbZu+|02c;2I&EogC@COgZ*FsR03&T_Zct%oWgx=4AX9Z>aA9X<0CRO>aA9X<E@*UZYy<#OWn*+<Zf9&|1ONvB00KHXQe|UwC@BI80S*Bd1snh%aA9X<ZeeX@b8ul}Wn*k%b8}{OZesud
\ No newline at end of file
import os
import sys
import pathlib
+sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__))))
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
-from doxygen import EntryType, search_type_map
+from _search_test_metadata import EntryType, search_type_map
from _search import Trie, ResultMap, ResultFlag, serialize_search_data
basedir = pathlib.Path(os.path.dirname(os.path.realpath(__file__)))/'js-test-data'
/* Verify that base85-decoded file is equivalent to the binary */
{
let binary = fs.readFileSync(path.join(__dirname, "js-test-data/searchdata.bin"));
- assert.equal(binary.byteLength, 745);
+ assert.equal(binary.byteLength, 674);
let b85 = fs.readFileSync(path.join(__dirname, "js-test-data/searchdata.b85"), {encoding: 'utf-8'});
assert.deepEqual(new DataView(binary.buffer.slice(binary.byteOffset, binary.byteOffset + binary.byteLength)), new DataView(Search.base85decode(b85), 0, binary.byteLength));
}
{
let buffer = fs.readFileSync(path.join(__dirname, "js-test-data/searchdata.bin"));
assert.ok(Search.init(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)));
- assert.equal(Search.dataSize, 745);
+ assert.equal(Search.dataSize, 674);
assert.equal(Search.symbolCount, 7);
assert.equal(Search.maxResults, 100);
{
let buffer = fs.readFileSync(path.join(__dirname, "js-test-data/searchdata.bin"));
assert.ok(Search.init(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength), 3));
- assert.equal(Search.dataSize, 745);
+ assert.equal(Search.dataSize, 674);
assert.equal(Search.symbolCount, 7);
assert.equal(Search.maxResults, 3);
assert.deepEqual(Search.search('m'), [[
{
let b85 = fs.readFileSync(path.join(__dirname, "js-test-data/searchdata.b85"), {encoding: 'utf-8'});
assert.ok(Search.load(b85));
- assert.equal(Search.dataSize, 748); /* some padding on the end, that's okay */
+ assert.equal(Search.dataSize, 676); /* some padding on the end, that's okay */
assert.equal(Search.symbolCount, 7);
assert.equal(Search.maxResults, 100);
assert.deepEqual(Search.search('min'), [[
{
let buffer = fs.readFileSync(path.join(__dirname, "js-test-data/unicode.bin"));
assert.ok(Search.init(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)));
- assert.equal(Search.dataSize, 231);
+ assert.equal(Search.dataSize, 160);
assert.equal(Search.symbolCount, 2);
/* Both "Hýždě" and "Hárá" have common autocompletion to "h\xA1", which is
not valid UTF-8, so it has to get truncated */
{
let buffer = fs.readFileSync(path.join(__dirname, "js-test-data/nested.bin"));
assert.ok(Search.init(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)));
- assert.equal(Search.dataSize, 402);
+ assert.equal(Search.dataSize, 331);
assert.equal(Search.symbolCount, 4);
assert.deepEqual(Search.search('geo'), [[
{ name: 'Magnum::Math::Geometry',
--- /dev/null
+#
+# This file is part of m.css.
+#
+# Copyright © 2017, 2018, 2019 Vladimír Vondruš <mosra@centrum.cz>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+import os
+import sys
+import unittest
+from types import SimpleNamespace as Empty
+
+from ._search_test_metadata import EntryType, search_type_map
+from _search import Trie, ResultMap, ResultFlag, serialize_search_data, pretty_print_trie, pretty_print_map, pretty_print, searchdata_filename
+
+from test_doxygen import IntegrationTestCase
+
+class TrieSerialization(unittest.TestCase):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.maxDiff = None
+
+ def compare(self, serialized: bytes, expected: str):
+ pretty = pretty_print_trie(serialized)[0]
+ #print(pretty)
+ self.assertEqual(pretty, expected.strip())
+
+ def test_empty(self):
+ trie = Trie()
+
+ serialized = trie.serialize()
+ self.compare(serialized, "")
+ self.assertEqual(len(serialized), 6)
+
+ def test_single(self):
+ trie = Trie()
+ trie.insert("magnum", 1337)
+ trie.insert("magnum", 21)
+
+ serialized = trie.serialize()
+ self.compare(serialized, """
+magnum [1337, 21]
+""")
+ self.assertEqual(len(serialized), 46)
+
+ def test_multiple(self):
+ trie = Trie()
+
+ trie.insert("math", 0)
+ trie.insert("math::vector", 1, lookahead_barriers=[4])
+ trie.insert("vector", 1)
+ trie.insert("math::range", 2)
+ trie.insert("range", 2)
+
+ trie.insert("math::min", 3)
+ trie.insert("min", 3)
+ trie.insert("math::max", 4)
+ trie.insert("max", 4)
+ trie.insert("math::minmax", 5)
+ trie.insert("minmax", 5)
+
+ trie.insert("math::vector::minmax", 6, lookahead_barriers=[4, 12])
+ trie.insert("vector::minmax", 6, lookahead_barriers=[6])
+ trie.insert("minmax", 6)
+ trie.insert("math::vector::min", 7)
+ trie.insert("vector::min", 7)
+ trie.insert("min", 7)
+ trie.insert("math::vector::max", 8)
+ trie.insert("vector::max", 8)
+ trie.insert("max", 8)
+
+ trie.insert("math::range::min", 9, lookahead_barriers=[4, 11])
+ trie.insert("range::min", 9, lookahead_barriers=[5])
+ trie.insert("min", 9)
+
+ trie.insert("math::range::max", 10)
+ trie.insert("range::max", 10)
+ trie.insert("max", 10)
+
+ serialized = trie.serialize()
+ self.compare(serialized, """
+math [0]
+||| :$
+||| :vector [1]
+||| | :$
+||| | :min [7]
+||| | | max [6]
+||| | ax [8]
+||| range [2]
+||| | :$
+||| | :min [9]
+||| | ax [10]
+||| min [3]
+||| || max [5]
+||| |ax [4]
+||x [4, 8, 10]
+|in [3, 7, 9]
+|| max [5, 6]
+vector [1]
+| :$
+| :min [7]
+| | max [6]
+| ax [8]
+range [2]
+| :$
+| :min [9]
+| ax [10]
+""")
+ self.assertEqual(len(serialized), 340)
+
+ def test_unicode(self):
+ trie = Trie()
+
+ trie.insert("hýždě", 0)
+ trie.insert("hárá", 1)
+
+ serialized = trie.serialize()
+ self.compare(serialized, """
+h0xc3
+ 0xbd
+ 0xc5
+ | 0xbe
+ | d0xc4
+ | 0x9b
+ | [0]
+ 0xa1
+ r0xc3
+ | 0xa1
+ | [1]
+""")
+ self.assertEqual(len(serialized), 82)
+
+class MapSerialization(unittest.TestCase):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.maxDiff = None
+
+ def compare(self, serialized: bytes, expected: str):
+ pretty = pretty_print_map(serialized, entryTypeClass=EntryType)
+ #print(pretty)
+ self.assertEqual(pretty, expected.strip())
+
+ def test_empty(self):
+ map = ResultMap()
+
+ serialized = map.serialize()
+ self.compare(serialized, "")
+ self.assertEqual(len(serialized), 4)
+
+ def test_single(self):
+ map = ResultMap()
+ self.assertEqual(map.add("Magnum", "namespaceMagnum.html", suffix_length=11, flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)), 0)
+
+ serialized = map.serialize()
+ self.compare(serialized, """
+0: Magnum [suffix_length=11, type=NAMESPACE] -> namespaceMagnum.html
+""")
+ self.assertEqual(len(serialized), 36)
+
+ def test_multiple(self):
+ map = ResultMap()
+
+ self.assertEqual(map.add("Math", "namespaceMath.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)), 0)
+ self.assertEqual(map.add("Math::Vector", "classMath_1_1Vector.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS)), 1)
+ self.assertEqual(map.add("Math::Range", "classMath_1_1Range.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS)), 2)
+ self.assertEqual(map.add("Math::min()", "namespaceMath.html#abcdef2875", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.FUNC)), 3)
+ self.assertEqual(map.add("Math::max(int, int)", "namespaceMath.html#abcdef1234", suffix_length=8, flags=ResultFlag.from_type(ResultFlag.DEPRECATED|ResultFlag.DELETED, EntryType.FUNC)), 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)
+
+class Serialization(unittest.TestCase):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.maxDiff = None
+
+ def compare(self, serialized: bytes, expected: str):
+ pretty = pretty_print(serialized, entryTypeClass=EntryType)[0]
+ #print(pretty)
+ self.assertEqual(pretty, expected.strip())
+
+ def test(self):
+ trie = Trie()
+ map = ResultMap()
+
+ trie.insert("math", map.add("Math", "namespaceMath.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)))
+ index = map.add("Math::Vector", "classMath_1_1Vector.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS))
+ trie.insert("math::vector", index)
+ trie.insert("vector", index)
+ index = map.add("Math::Range", "classMath_1_1Range.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS))
+ trie.insert("math::range", index)
+ trie.insert("range", index)
+
+ serialized = serialize_search_data(trie, map, search_type_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
+(EntryType.PAGE, CssClass.SUCCESS, 'page'),
+(EntryType.NAMESPACE, CssClass.PRIMARY, 'namespace'),
+(EntryType.CLASS, CssClass.PRIMARY, 'class'),
+(EntryType.FUNC, CssClass.INFO, 'func')
+""")
+ self.assertEqual(len(serialized), 277)
import argparse
import os
import sys
-import unittest
-from types import SimpleNamespace as Empty
-from doxygen import EntryType, search_type_map
-from _search import Trie, ResultMap, ResultFlag, serialize_search_data, pretty_print_trie, pretty_print_map, pretty_print, searchdata_filename
+from doxygen import EntryType
+from _search import pretty_print, searchdata_filename
from test_doxygen import IntegrationTestCase
-class TrieSerialization(unittest.TestCase):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.maxDiff = None
-
- def compare(self, serialized: bytes, expected: str):
- pretty = pretty_print_trie(serialized)[0]
- #print(pretty)
- self.assertEqual(pretty, expected.strip())
-
- def test_empty(self):
- trie = Trie()
-
- serialized = trie.serialize()
- self.compare(serialized, "")
- self.assertEqual(len(serialized), 6)
-
- def test_single(self):
- trie = Trie()
- trie.insert("magnum", 1337)
- trie.insert("magnum", 21)
-
- serialized = trie.serialize()
- self.compare(serialized, """
-magnum [1337, 21]
-""")
- self.assertEqual(len(serialized), 46)
-
- def test_multiple(self):
- trie = Trie()
-
- trie.insert("math", 0)
- trie.insert("math::vector", 1, lookahead_barriers=[4])
- trie.insert("vector", 1)
- trie.insert("math::range", 2)
- trie.insert("range", 2)
-
- trie.insert("math::min", 3)
- trie.insert("min", 3)
- trie.insert("math::max", 4)
- trie.insert("max", 4)
- trie.insert("math::minmax", 5)
- trie.insert("minmax", 5)
-
- trie.insert("math::vector::minmax", 6, lookahead_barriers=[4, 12])
- trie.insert("vector::minmax", 6, lookahead_barriers=[6])
- trie.insert("minmax", 6)
- trie.insert("math::vector::min", 7)
- trie.insert("vector::min", 7)
- trie.insert("min", 7)
- trie.insert("math::vector::max", 8)
- trie.insert("vector::max", 8)
- trie.insert("max", 8)
-
- trie.insert("math::range::min", 9, lookahead_barriers=[4, 11])
- trie.insert("range::min", 9, lookahead_barriers=[5])
- trie.insert("min", 9)
-
- trie.insert("math::range::max", 10)
- trie.insert("range::max", 10)
- trie.insert("max", 10)
-
- serialized = trie.serialize()
- self.compare(serialized, """
-math [0]
-||| :$
-||| :vector [1]
-||| | :$
-||| | :min [7]
-||| | | max [6]
-||| | ax [8]
-||| range [2]
-||| | :$
-||| | :min [9]
-||| | ax [10]
-||| min [3]
-||| || max [5]
-||| |ax [4]
-||x [4, 8, 10]
-|in [3, 7, 9]
-|| max [5, 6]
-vector [1]
-| :$
-| :min [7]
-| | max [6]
-| ax [8]
-range [2]
-| :$
-| :min [9]
-| ax [10]
-""")
- self.assertEqual(len(serialized), 340)
-
- def test_unicode(self):
- trie = Trie()
-
- trie.insert("hýždě", 0)
- trie.insert("hárá", 1)
-
- serialized = trie.serialize()
- self.compare(serialized, """
-h0xc3
- 0xbd
- 0xc5
- | 0xbe
- | d0xc4
- | 0x9b
- | [0]
- 0xa1
- r0xc3
- | 0xa1
- | [1]
-""")
- self.assertEqual(len(serialized), 82)
-
-class MapSerialization(unittest.TestCase):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.maxDiff = None
-
- def compare(self, serialized: bytes, expected: str):
- pretty = pretty_print_map(serialized, entryTypeClass=EntryType)
- #print(pretty)
- self.assertEqual(pretty, expected.strip())
-
- def test_empty(self):
- map = ResultMap()
-
- serialized = map.serialize()
- self.compare(serialized, "")
- self.assertEqual(len(serialized), 4)
-
- def test_single(self):
- map = ResultMap()
- self.assertEqual(map.add("Magnum", "namespaceMagnum.html", suffix_length=11, flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)), 0)
-
- serialized = map.serialize()
- self.compare(serialized, """
-0: Magnum [suffix_length=11, type=NAMESPACE] -> namespaceMagnum.html
-""")
- self.assertEqual(len(serialized), 36)
-
- def test_multiple(self):
- map = ResultMap()
-
- self.assertEqual(map.add("Math", "namespaceMath.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)), 0)
- self.assertEqual(map.add("Math::Vector", "classMath_1_1Vector.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS)), 1)
- self.assertEqual(map.add("Math::Range", "classMath_1_1Range.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS)), 2)
- self.assertEqual(map.add("Math::min()", "namespaceMath.html#abcdef2875", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.FUNC)), 3)
- self.assertEqual(map.add("Math::max(int, int)", "namespaceMath.html#abcdef1234", suffix_length=8, flags=ResultFlag.from_type(ResultFlag.DEPRECATED|ResultFlag.DELETED, EntryType.FUNC)), 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)
-
-class Serialization(unittest.TestCase):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.maxDiff = None
-
- def compare(self, serialized: bytes, expected: str):
- pretty = pretty_print(serialized, entryTypeClass=EntryType)[0]
- #print(pretty)
- self.assertEqual(pretty, expected.strip())
-
- def test(self):
- trie = Trie()
- map = ResultMap()
-
- trie.insert("math", map.add("Math", "namespaceMath.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.NAMESPACE)))
- index = map.add("Math::Vector", "classMath_1_1Vector.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS))
- trie.insert("math::vector", index)
- trie.insert("vector", index)
- index = map.add("Math::Range", "classMath_1_1Range.html", flags=ResultFlag.from_type(ResultFlag.NONE, EntryType.CLASS))
- trie.insert("math::range", index)
- trie.insert("range", index)
-
- serialized = serialize_search_data(trie, map, search_type_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
-(EntryType.PAGE, CssClass.SUCCESS, 'page'),
-(EntryType.NAMESPACE, CssClass.PRIMARY, 'namespace'),
-(EntryType.GROUP, CssClass.SUCCESS, 'group'),
-(EntryType.CLASS, CssClass.PRIMARY, 'class'),
-(EntryType.STRUCT, CssClass.PRIMARY, 'struct'),
-(EntryType.UNION, CssClass.PRIMARY, 'union'),
-(EntryType.TYPEDEF, CssClass.PRIMARY, 'typedef'),
-(EntryType.DIR, CssClass.WARNING, 'dir'),
-(EntryType.FILE, CssClass.WARNING, 'file'),
-(EntryType.FUNC, CssClass.INFO, 'func'),
-(EntryType.DEFINE, CssClass.INFO, 'define'),
-(EntryType.ENUM, CssClass.PRIMARY, 'enum'),
-(EntryType.ENUM_VALUE, CssClass.DEFAULT, 'enum val'),
-(EntryType.VAR, CssClass.DEFAULT, 'var')
-""")
- self.assertEqual(len(serialized), 348)
-
class Search(IntegrationTestCase):
def __init__(self, *args, **kwargs):
super().__init__(__file__, '', *args, **kwargs)
- if [ "$WITH_DOCUMENTATION" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation && coverage run -m unittest && cp .coverage ../.coverage.doxygen; fi
# Test client doxygen JS
- - if [ "$WITH_NODE" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation && node ../node_modules/istanbul/lib/cli.js cover test_doxygen/test-search.js; fi
+ - if [ "$WITH_NODE" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation && node ../node_modules/istanbul/lib/cli.js cover test/test-search.js; fi
# Test that compiled CSS is up-to-date. First display the diff, then check
# with diff-index which should print what's wrong and return with non-zero
# Test that JS search test data are up-to-date as well. Would be best to do
# it on the Node.js job but that one has just Python 3.5 which doesn't know
# enum.Flag.
- - if [ "$WITH_DOCUMENTATION" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation/test_doxygen && ./populate-js-test-data.py && git diff --color=always . | cat; fi
- - if [ "$WITH_DOCUMENTATION" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation/test_doxygen/js-test-data && git diff-index --exit-code HEAD -- .; fi
+ - if [ "$WITH_DOCUMENTATION" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation/test&& ./populate-js-test-data.py && git diff --color=always . | cat; fi
+ - if [ "$WITH_DOCUMENTATION" == "ON" ]; then cd $TRAVIS_BUILD_DIR/documentation/test/js-test-data && git diff-index --exit-code HEAD -- .; fi
# Cache the downloaded doxygen and pybind11
cache: