From 43cf096dcc2536e3f71ded65bab4f607817b0808 Mon Sep 17 00:00:00 2001 From: Matthew Hall <matthew@quickbeam.me.uk> Date: Fri, 3 Apr 2015 12:11:48 +0100 Subject: [PATCH] Actually test the csv parser. This commit also fixes a bug that meant the last cell of each row would not be parsed if the tmx file was base64 encoded. --- src/lib.rs | 2 +- tests/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b14dfaf..d88f712 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -554,7 +554,7 @@ fn convert_to_u32(all: &Vec<u8>, width: u32) -> Vec<Vec<u32>> { let mut data = Vec::new(); for chunk in all.chunks((width * 4) as usize) { let mut row = Vec::new(); - for i in 0 .. width - 1 { + for i in 0 .. width { let start: usize = i as usize * 4; let n = ((chunk[start + 3] as u32) << 24) + ((chunk[start + 2] as u32) << 16) + diff --git a/tests/lib.rs b/tests/lib.rs index 6d3659f..3e24cfb 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -17,4 +17,5 @@ fn test_gzip_and_zlib_encoded_and_raw_are_the_same() { let c = read_from_file(&Path::new("assets/tiled_csv.tmx")).unwrap(); assert_eq!(z, g); assert_eq!(z, r); + assert_eq!(z, c); } -- GitLab