From 5bf723928bf20e0d7a8680e70b9429255a7d225e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Mon, 6 Oct 2025 18:43:37 +0200 Subject: [PATCH] Update test assertions in main() --- src/main.rs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8217e97..5fc6937 100644 --- a/src/main.rs +++ b/src/main.rs @@ -165,41 +165,38 @@ fn main() { graph.add_edge(vertices[7], vertices[8]); graph.add_edge(vertices[7], vertices[9]); - assert_eq!(graph.vertex_count(), 10, "vertex count"); - assert_eq!(graph.edge_count(), 14, "edge count"); + assert_eq!(graph.vertex_count(), 10, "unexpected vertex count"); + assert_eq!(graph.edge_count(), 14, "unexpected edge count"); let expected_degrees = [1, 4, 4, 2, 4, 2, 3, 3, 2, 3]; for i in 0..graph.vertex_count() { assert_eq!( graph.degree(vertices[i]), expected_degrees[i], - "degree of {:?}", + "unexpected degree of {:?}", vertices[i] ); } - assert_eq!( + assert!( graph.are_adjacent(vertices[0], vertices[1]), - true, - "adjacency of {:?} and {:?}", + "expected {:?} and {:?} to be adjacent", vertices[0], vertices[1] ); - assert_eq!( + assert!( graph.are_adjacent(vertices[9], vertices[5]), - true, - "adjacency of {:?} and {:?}", + "expected {:?} and {:?} to be adjacent", vertices[0], vertices[5] ); - assert_eq!( - graph.are_adjacent(vertices[9], vertices[3]), - false, - "adjacency of {:?} and {:?}", + assert!( + !graph.are_adjacent(vertices[9], vertices[3]), + "unexpected adjacency of {:?} and {:?}", vertices[9], vertices[3] ); - for i in 0..vertices.len() { + for i in 0..graph.vertex_count() { let exp = match i { 2 => continue, 1 | 4 | 5 | 6 => true, @@ -208,14 +205,14 @@ fn main() { assert_eq!( graph.are_adjacent(vertices[2], vertices[i]), exp, - "adjacency of {:?} and {:?}", + "unexpected adjacency of {:?} and {:?}", vertices[2], vertices[i] ); assert_eq!( graph.are_adjacent(vertices[i], vertices[2]), exp, - "adjacency of {:?} and {:?}", + "unexpected adjacency of {:?} and {:?}", vertices[i], vertices[2] );