Skip to content

Commit

Permalink
Port std::* tests to new integration test style
Browse files Browse the repository at this point in the history
  • Loading branch information
GREsau committed Sep 9, 2024
1 parent fd16576 commit e33f9c1
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 374 deletions.
8 changes: 0 additions & 8 deletions schemars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ raw_value = ["serde_json/raw_value"]
# For internal/CI use only
_ui_test = []

[[test]]
name = "std_time"
required-features = ["std"]

[[test]]
name = "ffi"
required-features = ["std"]

[[test]]
name = "ui"
required-features = ["_ui_test"]
Expand Down
31 changes: 29 additions & 2 deletions schemars/src/json_schema_impls/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::SchemaGenerator;
use crate::_alloc_prelude::*;
use crate::{json_schema, JsonSchema, Schema};
use alloc::borrow::Cow;
use serde_json::json;
use std::ffi::{CStr, CString, OsStr, OsString};

impl JsonSchema for OsString {
Expand Down Expand Up @@ -37,5 +38,31 @@ impl JsonSchema for OsString {

forward_impl!(OsStr => OsString);

forward_impl!(CString => Vec<u8>);
forward_impl!(CStr => Vec<u8>);
impl JsonSchema for CString {
fn schema_name() -> Cow<'static, str> {
"CString".into()
}

fn schema_id() -> Cow<'static, str> {
"std::ffi::CString".into()
}

fn json_schema(generator: &mut SchemaGenerator) -> Schema {
let ty = if generator.contract().is_deserialize() {
json!(["array", "string"])
} else {
json!("array")
};

json_schema!({
"type": ty,
"items": {
"type": "integer",
"minimum": 1,
"maximum": 255
},
})
}
}

forward_impl!(CStr => CString);
57 changes: 0 additions & 57 deletions schemars/tests/expected/duration_and_systemtime.json

This file was deleted.

5 changes: 0 additions & 5 deletions schemars/tests/expected/no-variants.json

This file was deleted.

55 changes: 0 additions & 55 deletions schemars/tests/expected/os_strings.json

This file was deleted.

89 changes: 0 additions & 89 deletions schemars/tests/expected/range.json

This file was deleted.

86 changes: 0 additions & 86 deletions schemars/tests/expected/result.json

This file was deleted.

16 changes: 0 additions & 16 deletions schemars/tests/ffi.rs

This file was deleted.

3 changes: 1 addition & 2 deletions schemars/tests/integration/enums_flattened.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use schemars::generate::SchemaSettings;

use crate::prelude::*;
use schemars::generate::SchemaSettings;

macro_rules! fn_values {
() => {
Expand Down
1 change: 1 addition & 0 deletions schemars/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod enum_repr;
mod enums;
mod enums_deny_unknown_fields;
mod enums_flattened;
mod std_types;

mod prelude {
pub use crate::test;
Expand Down
Loading

0 comments on commit e33f9c1

Please sign in to comment.