Fix broken tests that I forgot to update.

This commit is contained in:
Nathan Vegdahl 2023-08-04 00:46:16 +02:00
parent f4b7767198
commit 79b9bd5f49

View File

@ -9,6 +9,7 @@ pub mod hilbert {
///
/// x: The x coordinate. Must be no greater than 2^16-1.
/// y: The y coordinate. Must be no greater than 2^16-1.
/// n: Basically the "resolution" of the curve, on one side.
///
/// Returns the hilbert curve index corresponding to the (x,y) coordinates given.
pub fn encode(x: u32, y: u32, n: u32) -> u32 {
@ -33,6 +34,7 @@ pub mod hilbert {
/// Convert hilbert curve index to (x,y).
///
/// d: The hilbert curve index.
/// n: Basically the "resolution" of the curve, on one side.
///
/// Returns the (x, y) coords at the given index.
pub fn decode(d: u32, n: u32) -> (u32, u32) {
@ -197,8 +199,8 @@ mod tests {
#[test]
fn hilbert_reversible() {
let i = 0x4c8587a2;
let (x, y) = hilbert::decode(i);
let i2 = hilbert::encode(x, y);
let (x, y) = hilbert::decode(i, 1 << 16);
let i2 = hilbert::encode(x, y, 1 << 16);
assert_eq!(i, i2);
}