diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-04-24 08:20:16 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-05-28 10:34:23 +0200 |
commit | 593248870db8e1f2b1499f807fbf99b35b385b91 (patch) | |
tree | 297b1b8715324ee040b1639ef48585cc81adbd54 /rtemsqual/tests/test_content_c.py | |
parent | content: Add Content base class (diff) | |
download | rtems-central-593248870db8e1f2b1499f807fbf99b35b385b91.tar.bz2 |
content: Add CContent
Diffstat (limited to 'rtemsqual/tests/test_content_c.py')
-rw-r--r-- | rtemsqual/tests/test_content_c.py | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/rtemsqual/tests/test_content_c.py b/rtemsqual/tests/test_content_c.py new file mode 100644 index 00000000..9aa6952a --- /dev/null +++ b/rtemsqual/tests/test_content_c.py @@ -0,0 +1,133 @@ +# SPDX-License-Identifier: BSD-2-Clause +""" Unit tests for the rtemsqual.content module. """ + +# Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +from rtemsqual.content import CContent + + +def test_add_have_config(): + content = CContent() + content.add_have_config() + assert content.content == """ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +""" + + +def test_add_lines(): + content = CContent() + content.add_lines("") + assert content.content == "" + content.add_lines("a\nb\n") + assert content.content == """a +b +""" + content.add_lines(["c", "d"], indent=1) + assert content.content == """a +b + c + d +""" + + +def test_add_line_block(): + content = CContent() + content.add_line_block("") + assert content.content == "" + content.add_line_block("a") + assert content.content == """ +a +""" + content.add_line_block(["b", "c"]) + assert content.content == """ +a + +b +c +""" + + +def test_add_includes(): + content = CContent() + content.add_includes([]) + assert content.content == "" + content = CContent() + content.add_includes(["a", "a"]) + assert content.content == """ +#include <a> +""" + content = CContent() + content.add_includes(["c", "b"], local=True) + assert content.content == """ +#include "b" +#include "c" +""" + content = CContent() + content.add_includes(["d/f", "d/e"]) + assert content.content == """ +#include <d/e> +#include <d/f> +""" + content = CContent() + content.add_includes(["h", "g/h"]) + assert content.content == """ +#include <h> +#include <g/h> +""" + content = CContent() + content.add_includes(["i/l/k", "i/j/k"]) + assert content.content == """ +#include <i/j/k> +#include <i/l/k> +""" + + +def test_add_comment_content(): + content = CContent() + content.add_comment_content("") + assert content.content == "" + content.add_comment_content("a") + assert content.content == """ * + * a +""" + + +def test_add_brief_description(): + content = CContent() + content.add_brief_description("") + assert content.content == "" + content.add_brief_description( + "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT " + "HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, " + "INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY " + "AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.") + assert content.content == """ * + * @brief THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. +""" |