Skip to content

Commit

Permalink
add roundtrip test for points2d archetype (rs)
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jul 4, 2023
1 parent 25b7b2a commit a79b20b
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"rerun_py",
"run_wasm",
"tests/rust/test_*",
"tests/rust/roundtrips/points2d",
]

[workspace.package]
Expand Down
13 changes: 13 additions & 0 deletions tests/rust/roundtrips/points2d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "roundtrip_points2d"
edition.workspace = true
license.workspace = true
publish = false
rust-version.workspace = true
version.workspace = true

[dependencies]
rerun = { path = "../../../../crates/rerun", features = ["native_viewer"] }

anyhow = "1.0"
clap = { version = "4.0", features = ["derive"] }
47 changes: 47 additions & 0 deletions tests/rust/roundtrips/points2d/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use rerun::{
components::Rect2D, experimental::archetypes::Points2D, external::re_log, MsgSender,
RecordingStream,
};

#[derive(Debug, clap::Parser)]
#[clap(author, version, about)]
struct Args {
#[command(flatten)]
rerun: rerun::clap::RerunArgs,
}

fn run(rec_stream: &RecordingStream, _args: &Args) -> anyhow::Result<()> {
MsgSender::from_archetype(
"points2d",
&Points2D::new([(1.0, 2.0), (3.0, 4.0)])
.with_radii([0.42, 0.43])
.with_colors([0xAA0000CC, 0x00BB00DD])
.with_labels(["hello", "friend"])
.with_draw_order(300.0)
.with_class_ids([126, 127])
.with_keypoint_ids([2, 3])
.with_instance_keys([66, 666]),
)?
.send(rec_stream)?;

// Hack to establish 2d view bounds
MsgSender::new("rect")
.with_component(&[Rect2D::from_xywh(0.0, 0.0, 4.0, 6.0)])?
.send(rec_stream)?;

Ok(())
}

fn main() -> anyhow::Result<()> {
re_log::setup_native_logging();

use clap::Parser as _;
let args = Args::parse();

let default_enabled = true;
args.rerun
.clone()
.run("roundtrip_points2d", default_enabled, move |rec_stream| {
run(&rec_stream, &args).unwrap();
})
}
8 changes: 4 additions & 4 deletions tests/rust/test_api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "test_api"
version = "0.8.0-alpha.0"
edition = "2021"
rust-version = "1.69"
license = "MIT OR Apache-2.0"
edition.workspace = true
license.workspace = true
publish = false
rust-version.workspace = true
version.workspace = true

[dependencies]
rerun = { path = "../../../crates/rerun", features = [
Expand Down

0 comments on commit a79b20b

Please sign in to comment.