#!/usr/bin/env python #===- test.py - ---------------------------------------------*- python -*--===# # # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # #===------------------------------------------------------------------------===# from gen_std import ParseSymbolPage, ParseIndexPage import unittest class TestStdGen(unittest.TestCase): def testParseIndexPage(self): html = """ abs() (int)
abs<>() (std::complex)
acos()
acosh() (since C++11)
as_bytes<>() (since C++20)
""" actual = ParseIndexPage(html) expected = [ ("abs", "abs.html", True), ("abs", "complex/abs.html", True), ("acos", "acos.html", False), ("acosh", "acosh.html", False), ("as_bytes", "as_bytes.html", False), ] self.assertEqual(len(actual), len(expected)) for i in range(0, len(actual)): self.assertEqual(expected[i][0], actual[i][0]) self.assertTrue(actual[i][1].endswith(expected[i][1])) self.assertEqual(expected[i][2], actual[i][2]) def testParseSymbolPage_SingleHeader(self): # Defined in header html = """
Defined in header <cmath>
void foo() this is matched
""" self.assertEqual(ParseSymbolPage(html, 'foo'), set([''])) def testParseSymbolPage_MulHeaders(self): # Defined in header # Defined in header # Defined in header html = """
Defined in header <cstddef>
void bar() this mentions foo, but isn't matched
Defined in header <cstdio>
Defined in header <cstdlib>
void foo() this is matched
""" self.assertEqual(ParseSymbolPage(html, "foo"), set(['', ''])) def testParseSymbolPage_MulHeadersInSameDiv(self): # Multile blocks in a Div. # Defined in header # Defined in header html = """
Defined in header <algorithm>
Defined in header <utility>
void foo() this is matched
""" self.assertEqual(ParseSymbolPage(html, "foo"), set(['', ''])) if __name__ == '__main__': unittest.main()