Skip to content

Commit 7209768

Browse files
committed
fix: derive Debug for all table row types
1 parent 3f2d7a9 commit 7209768

File tree

8 files changed

+23
-3
lines changed

8 files changed

+23
-3
lines changed

src/edge_table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{EdgeId, NodeId};
66
use ll_bindings::{tsk_edge_table_free, tsk_edge_table_init};
77

88
/// Row of an [`EdgeTable`]
9+
#[derive(Debug)]
910
pub struct EdgeTableRow {
1011
pub id: EdgeId,
1112
pub left: Position,

src/individual_table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::{tsk_id_t, tsk_size_t, TskitError};
77
use ll_bindings::{tsk_individual_table_free, tsk_individual_table_init};
88

99
/// Row of a [`IndividualTable`]
10+
#[derive(Debug)]
1011
pub struct IndividualTableRow {
1112
pub id: IndividualId,
1213
pub flags: IndividualFlags,

src/migration_table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{MigrationId, NodeId, PopulationId};
88
use ll_bindings::{tsk_migration_table_free, tsk_migration_table_init};
99

1010
/// Row of a [`MigrationTable`]
11+
#[derive(Debug)]
1112
pub struct MigrationTableRow {
1213
pub id: MigrationId,
1314
pub left: Position,

src/mutation_table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::{MutationId, NodeId, SiteId};
77
use ll_bindings::{tsk_mutation_table_free, tsk_mutation_table_init};
88

99
/// Row of a [`MutationTable`]
10+
#[derive(Debug)]
1011
pub struct MutationTableRow {
1112
pub id: MutationId,
1213
pub site: SiteId,

src/node_table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{IndividualId, NodeId, PopulationId};
88
use ll_bindings::{tsk_node_table_free, tsk_node_table_init};
99

1010
/// Row of a [`NodeTable`]
11+
#[derive(Debug)]
1112
pub struct NodeTableRow {
1213
pub id: NodeId,
1314
pub time: Time,

src/population_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::TskitError;
77
use ll_bindings::{tsk_population_table_free, tsk_population_table_init};
88

99
/// Row of a [`PopulationTable`]
10-
#[derive(Eq)]
10+
#[derive(Eq, Debug)]
1111
pub struct PopulationTableRow {
1212
pub id: PopulationId,
1313
pub metadata: Option<Vec<u8>>,

src/site_table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::TskitError;
88
use ll_bindings::{tsk_site_table_free, tsk_site_table_init};
99

1010
/// Row of a [`SiteTable`]
11+
#[derive(Debug)]
1112
pub struct SiteTableRow {
1213
pub id: SiteId,
1314
pub position: Position,

tests/test_tables.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,22 @@ mod test_adding_rows_without_metadata {
4545
// are held in an Option.
4646
match tables.$table().row(id) {
4747
Some(row) => {
48-
// assert_eq!(row, row);
49-
assert!(row.metadata.is_none())
48+
assert!(row.metadata.is_none());
49+
50+
// A row equals itself
51+
let row2 = tables.$table().row(id).unwrap();
52+
assert_eq!(row, row2);
53+
54+
// create a second row w/identical payload
55+
if let Ok(id2) = tables.$adder($($payload),*) {
56+
if let Some(row2) = tables.$table().row(id2) {
57+
// The rows have different id
58+
assert_ne!(row, row2);
59+
} else {
60+
panic!("Expected Some(row2) from {} table", stringify!(table))
61+
}
62+
}
63+
5064
},
5165
None => panic!("Expected Some(row) from {} table", stringify!(table))
5266
}

0 commit comments

Comments
 (0)