-
Notifications
You must be signed in to change notification settings - Fork 844
cmake: add tests for proxy/hdrs #10283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
49dad19
cmake: add tests for proxy/hdrs
cmcfarlen ab7ea69
convert huffman test to catch
cmcfarlen e9073b7
Use already existing catch2 target for tests
cmcfarlen b63aeae
don't use generator expression for simple target commands
cmcfarlen 83b331c
use catch2 target instead of include dir. undo hwloc link changes
cmcfarlen 6cecd1a
use corrent target
cmcfarlen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| #include <iostream> | ||
| #include <cassert> | ||
| #include <cstring> | ||
| #include "catch.hpp" | ||
|
|
||
| using namespace std; | ||
|
|
||
|
|
@@ -88,13 +89,20 @@ random_test() | |
| free(dst_start); | ||
| } | ||
|
|
||
| TEST_CASE("Huffmancode Random", "[proxy][huffman]") | ||
| { | ||
| // This doesn't check anything ... | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then why does it exist? |
||
| for (int i = 0; i < 100; i++) { | ||
| random_test(); | ||
| } | ||
| } | ||
|
|
||
| union Value { | ||
| uint32_t x; | ||
| uint8_t y[4]; | ||
| }; | ||
|
|
||
| void | ||
| values_test() | ||
| TEST_CASE("values_test", "[proxy][huffman]") | ||
| { | ||
| char dst_start[4]; | ||
| int size = sizeof(test_values) / 4; | ||
|
|
@@ -139,11 +147,11 @@ values_test() | |
|
|
||
| // EOS is treated as invalid so check for an error | ||
| if (value == 0x3fffffff) { | ||
| assert(bytes == -1); | ||
| REQUIRE(bytes == -1); | ||
| continue; | ||
| } | ||
| assert(dst_start[0] == ascii_value); | ||
| assert(bytes == 1); | ||
| REQUIRE(dst_start[0] == ascii_value); | ||
| REQUIRE(bytes == 1); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -164,22 +172,20 @@ const static struct { | |
| 17 } | ||
| }; | ||
|
|
||
| void | ||
| encode_test() | ||
| TEST_CASE("encode_test", "[proxy][huffman]") | ||
| { | ||
| for (const auto &i : huffman_encode_test_data) { | ||
| uint8_t *dst = static_cast<uint8_t *>(malloc(i.expect_len)); | ||
| int64_t encoded_len = huffman_encode(dst, i.src, i.src_len); | ||
|
|
||
| assert(encoded_len == i.expect_len); | ||
| assert(memcmp(i.expect, dst, encoded_len) == 0); | ||
| REQUIRE(encoded_len == i.expect_len); | ||
| REQUIRE(memcmp(i.expect, dst, encoded_len) == 0); | ||
|
|
||
| free(dst); | ||
| } | ||
| } | ||
|
|
||
| void | ||
| decode_errors_test() | ||
| TEST_CASE("decode_errors", "[proxy][huffman]") | ||
| { | ||
| const static struct { | ||
| char *input; | ||
|
|
@@ -196,24 +202,7 @@ decode_errors_test() | |
| int dst_len = 2 * test_cases[i].input_len; | ||
| char *dst = (char *)malloc(dst_len); | ||
| int len = huffman_decode(dst, (uint8_t *)test_cases[i].input, test_cases[i].input_len); | ||
| assert(len == -1); | ||
| REQUIRE(len == -1); | ||
| free(dst); | ||
| } | ||
| } | ||
|
|
||
| int | ||
| main() | ||
| { | ||
| hpack_huffman_init(); | ||
|
|
||
| for (int i = 0; i < 100; i++) { | ||
| random_test(); | ||
| } | ||
| values_test(); | ||
| decode_errors_test(); | ||
|
|
||
| hpack_huffman_fin(); | ||
|
|
||
| encode_test(); | ||
| return 0; | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also depends on tscpputil. Doesn't depend on libswoc (that I can find).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tscore needs libswoc but doesn't have it PUBLIC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It almost certainly should be PUBLIC.