Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pause125 authored and davidiw committed Dec 11, 2022
1 parent 8a661d1 commit 6d1a4cd
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion aptos-move/framework/aptos-stdlib/sources/comparator.move
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<u128>,
Expand Down

0 comments on commit 6d1a4cd

Please sign in to comment.