-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update warnings tests to check C++ and Python generators as well
- Loading branch information
Showing
31 changed files
with
1,175 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
set(ZSERIO_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/gen) | ||
set(ZSERIO_GENERATED_SOURCES | ||
${ZSERIO_GEN_DIR}/choice_types_warning/optional_references_in_selector/Selector.cpp | ||
${ZSERIO_GEN_DIR}/choice_types_warning/optional_references_in_selector/Selector.h | ||
${ZSERIO_GEN_DIR}/choice_types_warning/optional_references_in_selector/TestChoice.cpp | ||
${ZSERIO_GEN_DIR}/choice_types_warning/optional_references_in_selector/TestChoice.h | ||
) | ||
|
||
zserio_add_library(TARGET choice_types_warning_zs | ||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zs | ||
MAIN_SOURCE choice_types_warning.zs | ||
OUT_DIR ${ZSERIO_GEN_DIR} | ||
OUT_FILES ${ZSERIO_GENERATED_SOURCES} | ||
ZSERIO_CORE_DIR ${ZSERIO_JAR_DIR} | ||
ZSERIO_CPP_DIR ${ZSERIO_CPP_DISTR_DIR} | ||
ZSERIO_OPTIONS -withoutSourcesAmalgamation | ||
EXPECTED_WARNINGS 1 | ||
ZSERIO_LOG_FILENAME zserio_log.txt | ||
) | ||
|
||
add_test_sources( | ||
cpp/ChoiceTypesWarningTest.cpp | ||
) | ||
|
||
add_test_dependencies(choice_types_warning_zs) |
23 changes: 23 additions & 0 deletions
23
test/warnings/choice_types_warning/cpp/ChoiceTypesWarningTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "test_utils/ZserioErrorOutput.h" | ||
|
||
class ChoiceTypesWarningTest : public ::testing::Test | ||
{ | ||
protected: | ||
ChoiceTypesWarningTest() | ||
: zserioWarnings("warnings/choice_types_warning") | ||
{} | ||
|
||
const test_utils::ZserioErrorOutput zserioWarnings; | ||
}; | ||
|
||
TEST_F(ChoiceTypesWarningTest, optionalReferencesInSelector) | ||
{ | ||
const std::string warning = "optional_references_in_selector.zs:8:41: Choice 'TestChoice' selector " | ||
"contains reference to optional field 'numBits'."; | ||
ASSERT_TRUE(zserioWarnings.isPresent(warning)); | ||
} |
1 change: 1 addition & 0 deletions
1
test/warnings/choice_types_warning/cpp/CppcheckSuppressions.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uninitMemberVar:*/choice_types_warning/optional_references_in_selector/TestChoice.cpp |
19 changes: 19 additions & 0 deletions
19
test/warnings/choice_types_warning/python/ChoiceTypesWarningTest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import unittest | ||
|
||
from testutils import getZserioApi, assertWarningsPresent | ||
|
||
class ArrayTypesWarningTest(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
cls.warnings = {} | ||
cls.api = getZserioApi(__file__, "choice_types_warning.zs", | ||
expectedWarnings=1, errorOutputDict=cls.warnings) | ||
|
||
def testOptionalReferencesInSelector(self): | ||
assertWarningsPresent(self, | ||
"choice_types_warning.zs", | ||
[ | ||
"optional_references_in_selector.zs:8:41: Choice 'TestChoice' selector " | ||
"contains reference to optional field 'numBits'." | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
set(ZSERIO_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/gen) | ||
set(ZSERIO_GENERATED_SOURCES | ||
${ZSERIO_GEN_DIR}/comments_warning/markdown_comment_with_wrong_terminator/OtherTestStruct.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/markdown_comment_with_wrong_terminator/OtherTestStruct.h | ||
${ZSERIO_GEN_DIR}/comments_warning/markdown_comment_with_wrong_terminator/TestDatabase.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/markdown_comment_with_wrong_terminator/TestDatabase.h | ||
${ZSERIO_GEN_DIR}/comments_warning/markdown_comment_with_wrong_terminator/TestStruct.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/markdown_comment_with_wrong_terminator/TestStruct.h | ||
${ZSERIO_GEN_DIR}/comments_warning/markdown_comment_with_wrong_terminator/TestTable.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/markdown_comment_with_wrong_terminator/TestTable.h | ||
|
||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_in_templated_struct/TemplatedStructString.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_in_templated_struct/TemplatedStructString.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_in_templated_struct/TemplatedStructUInt32.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_in_templated_struct/TemplatedStructUInt32.h | ||
|
||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_reference/Database.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_reference/Database.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_reference/Table.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_reference/Table.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_reference/Test.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_reference/Test.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unresolved_see_tag_reference/VALUE.h | ||
|
||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/BasicComment.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/BasicComment.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/ByAlignmentAndType.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/ByAlignmentAndType.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/ByIndexedOffsetAndType.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/ByIndexedOffsetAndType.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/ByOffsetAndType.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/ByOffsetAndType.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/ByOptionalAndType.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/ByOptionalAndType.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/Database.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/Database.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/MultipleComments.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/MultipleComments.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/MultipleFieldComments.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/MultipleFieldComments.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/MultipleUnmaskedComments.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/MultipleUnmaskedComments.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/Table.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/Table.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/UnusedCommentById.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_field_comments/UnusedCommentById.h | ||
|
||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_by_id/Database.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_by_id/Database.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_by_id/Table.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_by_id/Table.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_by_id/Test.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_by_id/Test.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_multiple_comments/Database.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_multiple_comments/Database.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_multiple_comments/Table.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_multiple_comments/Table.h | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_multiple_comments/Test.cpp | ||
${ZSERIO_GEN_DIR}/comments_warning/unused_struct_comment_multiple_comments/Test.h | ||
) | ||
|
||
zserio_add_library(TARGET comments_warning_zs | ||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zs | ||
MAIN_SOURCE comments_warning.zs | ||
OUT_DIR ${ZSERIO_GEN_DIR} | ||
OUT_FILES ${ZSERIO_GENERATED_SOURCES} | ||
ZSERIO_CORE_DIR ${ZSERIO_JAR_DIR} | ||
ZSERIO_CPP_DIR ${ZSERIO_CPP_DISTR_DIR} | ||
ZSERIO_OPTIONS -withoutSourcesAmalgamation | ||
EXPECTED_WARNINGS 13 | ||
ZSERIO_LOG_FILENAME zserio_log.txt | ||
) | ||
|
||
target_include_directories(comments_warning_zs SYSTEM PRIVATE ${SQLITE_INCDIR}) | ||
|
||
add_test_sources( | ||
cpp/CommentsWarningTest.cpp | ||
) | ||
|
||
add_test_dependencies(comments_warning_zs) |
74 changes: 74 additions & 0 deletions
74
test/warnings/comments_warning/cpp/CommentsWarningTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "test_utils/ZserioErrorOutput.h" | ||
|
||
class CommentsWarningTest : public ::testing::Test | ||
{ | ||
protected: | ||
CommentsWarningTest() | ||
: zserioWarnings("warnings/comments_warning") | ||
{} | ||
|
||
const test_utils::ZserioErrorOutput zserioWarnings; | ||
}; | ||
|
||
TEST_F(CommentsWarningTest, markdownCommentWithWrongTerminator) | ||
{ | ||
ASSERT_TRUE(zserioWarnings.isPresent("markdown_comment_with_wrong_terminator.zs:3:1: " | ||
"Markdown documentation comment should be terminated by '!*/'!")); | ||
|
||
ASSERT_TRUE(zserioWarnings.isPresent("markdown_comment_with_wrong_terminator.zs:7:1: " | ||
"Markdown documentation comment should be terminated by '!*/'!")); | ||
|
||
ASSERT_TRUE(zserioWarnings.isPresent("markdown_comment_with_wrong_terminator.zs:21:1: " | ||
"Markdown documentation comment should be terminated by '!*/'!")); | ||
|
||
ASSERT_TRUE(zserioWarnings.isPresent("markdown_comment_with_wrong_terminator.zs:26:5: " | ||
"Markdown documentation comment should be terminated by '!*/'!")); | ||
|
||
ASSERT_TRUE(zserioWarnings.isPresent("markdown_comment_with_wrong_terminator.zs:38:5: " | ||
"Markdown documentation comment should be terminated by '!*/'!")); | ||
} | ||
|
||
TEST_F(CommentsWarningTest, unresolvedSeeTagInTemplatedStruct) | ||
{ | ||
ASSERT_TRUE(zserioWarnings.isPresent("unresolved_see_tag_in_templated_struct.zs:3:5: " | ||
"Documentation: Unresolved referenced symbol 'unknown' for type 'TemplatedStruct'!")); | ||
} | ||
|
||
TEST_F(CommentsWarningTest, unresolvedSeeTagReference) | ||
{ | ||
ASSERT_TRUE(zserioWarnings.isPresent("unresolved_see_tag_reference.zs:8:4: " | ||
"Documentation: Unresolved referenced symbol 'Unexisting'!")); | ||
|
||
ASSERT_TRUE(zserioWarnings.isPresent("unresolved_see_tag_reference.zs:15:4: " | ||
"Documentation: Unresolved referenced symbol 'Unexisting' for type 'Table'!")); | ||
} | ||
|
||
TEST_F(CommentsWarningTest, unusedFieldComments) | ||
{ | ||
ASSERT_TRUE(zserioWarnings.isPresent( | ||
"unused_field_comments.zs:11:11: Documentation comment is not used!")); | ||
|
||
ASSERT_TRUE(zserioWarnings.isPresent( | ||
"unused_field_comments.zs:55:45: Documentation comment is not used!")); | ||
|
||
ASSERT_TRUE(zserioWarnings.isPresent( | ||
"unused_field_comments.zs:61:45: Documentation comment is not used!")); | ||
} | ||
|
||
TEST_F(CommentsWarningTest, unusedStructCommentById) | ||
{ | ||
const std::string warning = "unused_struct_comment_by_id.zs:3:8: Documentation comment is not used!"; | ||
ASSERT_TRUE(zserioWarnings.isPresent(warning)); | ||
} | ||
|
||
TEST_F(CommentsWarningTest, unusedStructCommentMultipleComments) | ||
{ | ||
const std::string warning = "unused_struct_comment_multiple_comments.zs:5:9: " | ||
"Documentation comment is not used!"; | ||
ASSERT_TRUE(zserioWarnings.isPresent(warning)); | ||
} |
115 changes: 115 additions & 0 deletions
115
test/warnings/comments_warning/python/CommentsWarningTest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import unittest | ||
|
||
from testutils import getZserioApi, assertWarningsPresent | ||
|
||
class CommentsWarningTest(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
cls.warnings = {} | ||
cls.api = getZserioApi(__file__, "comments_warning.zs", | ||
expectedWarnings=13, errorOutputDict=cls.warnings) | ||
|
||
def testMarkdownCommentWithWrongTerminator(self): | ||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"markdown_comment_with_wrong_terminator.zs:3:1: " | ||
"Markdown documentation comment should be terminated by '!*/'!" | ||
] | ||
) | ||
|
||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"markdown_comment_with_wrong_terminator.zs:7:1: " | ||
"Markdown documentation comment should be terminated by '!*/'!" | ||
] | ||
) | ||
|
||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"markdown_comment_with_wrong_terminator.zs:21:1: " | ||
"Markdown documentation comment should be terminated by '!*/'!" | ||
] | ||
) | ||
|
||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"markdown_comment_with_wrong_terminator.zs:26:5: " | ||
"Markdown documentation comment should be terminated by '!*/'!" | ||
] | ||
) | ||
|
||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"markdown_comment_with_wrong_terminator.zs:38:5: " | ||
"Markdown documentation comment should be terminated by '!*/'!" | ||
] | ||
) | ||
|
||
def testUnresolvedSeeTagInTemplatedStruct(self): | ||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"unresolved_see_tag_in_templated_struct.zs:3:5: " | ||
"Documentation: Unresolved referenced symbol 'unknown' for type 'TemplatedStruct'!" | ||
] | ||
) | ||
|
||
def testUnresolvedSeeTagReference(self): | ||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"unresolved_see_tag_reference.zs:8:4: " | ||
"Documentation: Unresolved referenced symbol 'Unexisting'!" | ||
] | ||
) | ||
|
||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"unresolved_see_tag_reference.zs:15:4: " | ||
"Documentation: Unresolved referenced symbol 'Unexisting' for type 'Table'!" | ||
] | ||
) | ||
|
||
def testUnusedFieldComments(self): | ||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"unused_field_comments.zs:11:11: Documentation comment is not used!" | ||
] | ||
) | ||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"unused_field_comments.zs:55:45: Documentation comment is not used!" | ||
] | ||
) | ||
|
||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"unused_field_comments.zs:61:45: Documentation comment is not used!" | ||
] | ||
) | ||
|
||
def testUnusedStructCommentById(self): | ||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"unused_struct_comment_by_id.zs:3:8: Documentation comment is not used!" | ||
] | ||
) | ||
|
||
def testUnusedStructCommentMultipleComments(self): | ||
assertWarningsPresent(self, | ||
"comments_warning.zs", | ||
[ | ||
"unused_struct_comment_multiple_comments.zs:5:9: " | ||
"Documentation comment is not used!" | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.