Skip to content

Commit

Permalink
fix clippy lints in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Dec 31, 2020
1 parent 0c25a25 commit 9a2f8e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
3 changes: 3 additions & 0 deletions examples/cargo/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// theoretically this should be safe, as unit tests are built without
// optimizations
#![allow(clippy::assertions_on_constants)]
mod test {
#[test]
fn test_env_contents() {
Expand Down
20 changes: 6 additions & 14 deletions examples/ffi/rust_calling_c/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,34 +117,26 @@ mod test {

#[test]
fn test_size() {
let matrix = Matrix::new(2, 4, &vec![11, 12, 13, 14,
21, 22, 23, 24]);
let matrix = Matrix::new(2, 4, &[11, 12, 13, 14, 21, 22, 23, 24]);
assert_eq!(2, matrix.rows());
assert_eq!(4, matrix.cols());
}

#[test]
fn test_equal() {
let matrix_a = Matrix::new(2, 4, &vec![11, 12, 13, 14,
21, 22, 23, 24]);
let matrix_b = Matrix::new(2, 4, &vec![11, 12, 13, 14,
21, 22, 23, 24]);
let matrix_a = Matrix::new(2, 4, &[11, 12, 13, 14, 21, 22, 23, 24]);
let matrix_b = Matrix::new(2, 4, &[11, 12, 13, 14, 21, 22, 23, 24]);
assert!(matrix_a.equal(&matrix_b));

let matrix_c = Matrix::new(2, 4, &vec![12, 13, 14, 15,
23, 24, 25, 26]);
let matrix_c = Matrix::new(2, 4, &[12, 13, 14, 15, 23, 24, 25, 26]);
assert!(!matrix_a.equal(&matrix_c));
}

#[test]
fn test_transpose() {
let mut matrix = Matrix::new(2, 4, &vec![11, 12, 13, 14,
21, 22, 23, 24]);
let mut matrix = Matrix::new(2, 4, &[11, 12, 13, 14, 21, 22, 23, 24]);
matrix.transpose();
let expected = Matrix::new(4, 2, &vec![11, 21,
12, 22,
13, 23,
14, 24]);
let expected = Matrix::new(4, 2, &[11, 21, 12, 22, 13, 23, 14, 24]);
assert!(matrix.equal(&expected));
}
}

0 comments on commit 9a2f8e2

Please sign in to comment.