-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C++: Fix polymorphic lookup and add tests (#576)
The previous iteration does not make ASAN happy because of the implicit static cast between Message and concrete type. This PR reverts that change, adds a new abstract validation registry, and explicitly performs a dynamic cast when asked to do so. It also checks to make sure a validator exists for the passed in message. Also add a .clang-format so at least manual formatting can be done. Signed-off-by: Matt Klein <mklein@lyft.com>
- Loading branch information
1 parent
d4f85cd
commit 4694024
Showing
7 changed files
with
119 additions
and
46 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,16 @@ | ||
--- | ||
Language: Cpp | ||
AccessModifierOffset: -2 | ||
ColumnLimit: 100 | ||
DerivePointerAlignment: false | ||
PointerAlignment: Left | ||
SortIncludes: false | ||
... | ||
|
||
--- | ||
Language: Proto | ||
ColumnLimit: 100 | ||
SpacesInContainerLiterals: false | ||
AllowShortFunctionsOnASingleLine: false | ||
ReflowComments: false | ||
... |
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
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
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
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,5 @@ | ||
syntax = "proto3"; | ||
|
||
package tests.harness.cc; | ||
|
||
message Foo {} |
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,21 @@ | ||
#include "tests/harness/cases/bool.pb.h" | ||
#include "tests/harness/cc/other.pb.h" | ||
#include "validate/validate.h" | ||
|
||
int main() { | ||
tests::harness::cc::Foo foo; | ||
|
||
// This does not have an associated validator but should still pass. | ||
std::string err; | ||
if (!pgv::BaseValidator::AbstractCheckMessage(foo, &err)) { | ||
return EXIT_FAILURE; | ||
} | ||
|
||
tests::harness::cases::BoolConstTrue bool_const_true; | ||
bool_const_true.set_val(false); | ||
if (pgv::BaseValidator::AbstractCheckMessage(bool_const_true, &err)) { | ||
return EXIT_FAILURE; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} |
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