-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a custom deserializer instead of wrapper types (#6)
- Loading branch information
Showing
30 changed files
with
3,943 additions
and
1,166 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 |
---|---|---|
@@ -1,4 +1,26 @@ | ||
codecov: | ||
require_ci_to_pass: yes | ||
bot: romac | ||
|
||
coverage: | ||
precision: 2 | ||
round: nearest | ||
range: "50...100" | ||
|
||
status: | ||
project: | ||
default: | ||
target: auto | ||
threshold: 5% | ||
removed_code_behavior: adjust_base | ||
paths: | ||
- "itf" | ||
patch: | ||
default: | ||
target: auto | ||
threshold: 5% | ||
paths: | ||
- "itf" | ||
|
||
changes: | ||
default: | ||
informational: true |
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 |
---|---|---|
@@ -1,31 +1,41 @@ | ||
name: Coverage | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: main | ||
paths: | ||
- itf/** | ||
pull_request: | ||
paths: | ||
- itf/** | ||
|
||
jobs: | ||
coverage: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: itf | ||
env: | ||
CARGO_TERM_COLOR: always | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Rust toolchain | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
toolchain: nightly | ||
components: llvm-tools-preview | ||
- name: Install cargo-nextest | ||
uses: taiki-e/install-action@cargo-nextest | ||
- name: Install cargo-llvm-cov | ||
uses: taiki-e/install-action@cargo-llvm-cov | ||
- name: Install cargo-nextest | ||
uses: taiki-e/install-action@nextest | ||
- name: Generate code coverage | ||
run: cargo llvm-cov nextest --all-features --workspace --lcov --output-path lcov.info | ||
- name: Generate text report | ||
run: cargo llvm-cov report | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos | ||
files: lcov.info | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: itf/lcov.info | ||
fail_ci_if_error: true |
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,48 @@ | ||
#![allow(dead_code)] | ||
|
||
use std::collections::{BTreeMap, BTreeSet}; | ||
|
||
use serde::Deserialize; | ||
|
||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize)] | ||
enum Bank { | ||
#[serde(rename = "N")] | ||
North, | ||
|
||
#[serde(rename = "W")] | ||
West, | ||
|
||
#[serde(rename = "E")] | ||
East, | ||
|
||
#[serde(rename = "S")] | ||
South, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize)] | ||
enum Person { | ||
#[serde(rename = "c1_OF_PERSON")] | ||
Cannibal1, | ||
|
||
#[serde(rename = "c2_OF_PERSON")] | ||
Cannibal2, | ||
|
||
#[serde(rename = "m1_OF_PERSON")] | ||
Missionary1, | ||
|
||
#[serde(rename = "m2_OF_PERSON")] | ||
Missionary2, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
struct State { | ||
pub bank_of_boat: Bank, | ||
pub who_is_on_bank: BTreeMap<Bank, BTreeSet<Person>>, | ||
} | ||
|
||
fn main() { | ||
let data = include_str!("../tests/fixtures/MissionariesAndCannibals.itf.json"); | ||
let trace: itf::Trace<State> = itf::trace_from_str(data).unwrap(); | ||
|
||
dbg!(trace); | ||
} |
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,20 @@ | ||
use serde::de::DeserializeOwned; | ||
|
||
use crate::Value; | ||
|
||
mod error; | ||
pub use error::Error; | ||
|
||
mod helpers; | ||
pub use helpers::As; | ||
pub use helpers::Integer; | ||
|
||
mod deserializer; | ||
|
||
#[doc(hidden)] | ||
pub fn decode_value<T>(value: Value) -> Result<T, Error> | ||
where | ||
T: DeserializeOwned, | ||
{ | ||
T::deserialize(value) | ||
} |
Oops, something went wrong.