Skip to content
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

support required fields #193

Merged
merged 1 commit into from
Jul 12, 2023
Merged

support required fields #193

merged 1 commit into from
Jul 12, 2023

Conversation

qicosmos
Copy link
Owner

If defined required fields, but the xml string lack of required fileds, iguana will throw exception.

struct some_book {
  std::string_view title;
  std::string_view author;
};
REFLECTION(some_book, title, author);
REQUIRED(some_book, title, author);

TEST_CASE("test required filed") {
  some_book book{"book", "tom"};
  std::string xml_str;
  iguana::to_xml(book, xml_str);

  std::cout << xml_str << "\n";

  std::string s1 = R"(<book_t><title>book</title></book_t>)";
  some_book b;
  CHECK_THROWS_AS(iguana::from_xml(b, s1), std::invalid_argument);

  std::string s2 = R"(<book_t><author>tom</author></book_t>)";
  CHECK_THROWS_AS(iguana::from_xml(b, s2), std::invalid_argument);
}

@codecov-commenter
Copy link

codecov-commenter commented Jul 12, 2023

Codecov Report

Patch coverage: 90.00% and project coverage change: +0.01 🎉

Comparison is base (37a5426) 42.49% compared to head (c12da6f) 42.50%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #193      +/-   ##
==========================================
+ Coverage   42.49%   42.50%   +0.01%     
==========================================
  Files          44       44              
  Lines        5210     5220      +10     
==========================================
+ Hits         2214     2219       +5     
- Misses       2996     3001       +5     
Impacted Files Coverage Δ
iguana/reflection.hpp 100.00% <ø> (ø)
iguana/xml_reader.hpp 33.33% <50.00%> (+33.33%) ⬆️
test/test_xml.cpp 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@qicosmos qicosmos merged commit 5ea414b into master Jul 12, 2023
11 checks passed
@qicosmos qicosmos deleted the support_required_fields branch July 12, 2023 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants