From 6d1a4cd6fee230392830629f7ba33d835ec17084 Mon Sep 17 00:00:00 2001 From: 0xpause Date: Wed, 7 Dec 2022 21:41:55 +0800 Subject: [PATCH] fix --- .../aptos-stdlib/sources/comparator.move | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/aptos-move/framework/aptos-stdlib/sources/comparator.move b/aptos-move/framework/aptos-stdlib/sources/comparator.move index 0c5c04c6cfda9..600a8ab88df87 100644 --- a/aptos-move/framework/aptos-stdlib/sources/comparator.move +++ b/aptos-move/framework/aptos-stdlib/sources/comparator.move @@ -86,7 +86,8 @@ module aptos_std::comparator { #[test] #[expected_failure] - public fun test_u128() { + public fun test_integer() { + // 1(0x1) will be larger than 256(0x100) after BCS serialization. let value0: u128 = 1; let value1: u128 = 256; @@ -97,6 +98,26 @@ module aptos_std::comparator { assert!(is_greater_than(&compare(&value1, &value0)), 3); } + #[test] + public fun test_u128() { + let value0: u128 = 5; + let value1: u128 = 152; + let value2: u128 = 511; // 0x1ff + + assert!(is_equal(&compare(&value0, &value0)), 0); + assert!(is_equal(&compare(&value1, &value1)), 1); + assert!(is_equal(&compare(&value2, &value2)), 2); + + assert!(is_smaller_than(&compare(&value0, &value1)), 2); + assert!(is_greater_than(&compare(&value1, &value0)), 3); + + assert!(is_smaller_than(&compare(&value0, &value2)), 3); + assert!(is_greater_than(&compare(&value2, &value0)), 4); + + assert!(is_smaller_than(&compare(&value1, &value2)), 5); + assert!(is_greater_than(&compare(&value2, &value1)), 6); + } + #[test_only] struct Complex has drop { value0: vector,