Skip to content

Commit

Permalink
Update tests, too
Browse files Browse the repository at this point in the history
  • Loading branch information
cgswords committed Feb 29, 2024
1 parent a129cc4 commit 2b23fbf
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 104 deletions.
22 changes: 11 additions & 11 deletions crates/sui-framework/packages/move-stdlib/tests/ascii_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ module std::ascii_tests {

#[test]
fun test_ascii_chars() {
let i = 0;
let mut i = 0;
let end = 128;
let vec = vector::empty();
let mut vec = vector::empty();

while (i < end) {
assert!(ascii::is_valid_char(i), 0);
Expand All @@ -29,9 +29,9 @@ module std::ascii_tests {

#[test]
fun test_ascii_push_chars() {
let i = 0;
let mut i = 0;
let end = 128;
let str = ascii::string(vector::empty());
let mut str = ascii::string(vector::empty());

while (i < end) {
ascii::push_char(&mut str, ascii::char(i));
Expand All @@ -45,9 +45,9 @@ module std::ascii_tests {

#[test]
fun test_ascii_push_char_pop_char() {
let i = 0;
let mut i = 0;
let end = 128;
let str = ascii::string(vector::empty());
let mut str = ascii::string(vector::empty());

while (i < end) {
ascii::push_char(&mut str, ascii::char(i));
Expand All @@ -67,9 +67,9 @@ module std::ascii_tests {

#[test]
fun test_printable_chars() {
let i = 0x20;
let mut i = 0x20;
let end = 0x7E;
let vec = vector::empty();
let mut vec = vector::empty();

while (i <= end) {
assert!(ascii::is_printable_char(i), 0);
Expand All @@ -95,7 +95,7 @@ module std::ascii_tests {

#[test]
fun test_invalid_ascii_characters() {
let i = 128u8;
let mut i = 128u8;
let end = 255u8;
while (i < end) {
let try_str = ascii::try_string(vector::singleton(i));
Expand All @@ -106,15 +106,15 @@ module std::ascii_tests {

#[test]
fun test_nonvisible_chars() {
let i = 0;
let mut i = 0;
let end = 0x09;
while (i < end) {
let str = ascii::string(vector::singleton(i));
assert!(!ascii::all_characters_printable(&str), 0);
i = i + 1;
};

let i = 0x0B;
let mut i = 0x0B;
let end = 0x0F;
while (i <= end) {
let str = ascii::string(vector::singleton(i));
Expand Down
14 changes: 7 additions & 7 deletions crates/sui-framework/packages/move-stdlib/tests/bcs_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
module std::bcs_tests {
use std::bcs;

struct Box<T> has copy, drop, store { x: T }
struct Box3<T> has copy, drop, store { x: Box<Box<T>> }
struct Box7<T> has copy, drop, store { x: Box3<Box3<T>> }
struct Box15<T> has copy, drop, store { x: Box7<Box7<T>> }
struct Box31<T> has copy, drop, store { x: Box15<Box15<T>> }
struct Box63<T> has copy, drop, store { x: Box31<Box31<T>> }
struct Box127<T> has copy, drop, store { x: Box63<Box63<T>> }
public struct Box<T> has copy, drop, store { x: T }
public struct Box3<T> has copy, drop, store { x: Box<Box<T>> }
public struct Box7<T> has copy, drop, store { x: Box3<Box3<T>> }
public struct Box15<T> has copy, drop, store { x: Box7<Box7<T>> }
public struct Box31<T> has copy, drop, store { x: Box15<Box15<T>> }
public struct Box63<T> has copy, drop, store { x: Box31<Box31<T>> }
public struct Box127<T> has copy, drop, store { x: Box63<Box63<T>> }

#[test]
fun bcs_address() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ module std::bit_vector_tests {

#[test_only]
fun test_bitvector_set_unset_of_size(k: u64) {
let bitvector = bit_vector::new(k);
let index = 0;
let mut bitvector = bit_vector::new(k);
let mut index = 0;
while (index < k) {
bit_vector::set(&mut bitvector, index);
assert!(bit_vector::is_index_set(&bitvector, index), 0);
index = index + 1;
let index_to_right = index;
let mut index_to_right = index;
while (index_to_right < k) {
assert!(!bit_vector::is_index_set(&bitvector, index_to_right), 1);
index_to_right = index_to_right + 1;
Expand All @@ -28,7 +28,7 @@ module std::bit_vector_tests {
bit_vector::unset(&mut bitvector, index);
assert!(!bit_vector::is_index_set(&bitvector, index), 0);
index = index + 1;
let index_to_right = index;
let mut index_to_right = index;
while (index_to_right < k) {
assert!(bit_vector::is_index_set(&bitvector, index_to_right), 1);
index_to_right = index_to_right + 1;
Expand All @@ -39,21 +39,21 @@ module std::bit_vector_tests {
#[test]
#[expected_failure(abort_code = bit_vector::EINDEX)]
fun set_bit_out_of_bounds() {
let bitvector = bit_vector::new(bit_vector::word_size());
let mut bitvector = bit_vector::new(bit_vector::word_size());
bit_vector::set(&mut bitvector, bit_vector::word_size());
}

#[test]
#[expected_failure(abort_code = bit_vector::EINDEX)]
fun unset_bit_out_of_bounds() {
let bitvector = bit_vector::new(bit_vector::word_size());
let mut bitvector = bit_vector::new(bit_vector::word_size());
bit_vector::unset(&mut bitvector, bit_vector::word_size());
}

#[test]
#[expected_failure(abort_code = bit_vector::EINDEX)]
fun index_bit_out_of_bounds() {
let bitvector = bit_vector::new(bit_vector::word_size());
let mut bitvector = bit_vector::new(bit_vector::word_size());
bit_vector::is_index_set(&mut bitvector, bit_vector::word_size());
}

Expand All @@ -75,7 +75,7 @@ module std::bit_vector_tests {

#[test]
fun longest_sequence_one_set_zero_index() {
let bitvector = bit_vector::new(100);
let mut bitvector = bit_vector::new(100);
bit_vector::set(&mut bitvector, 1);
assert!(bit_vector::longest_set_sequence_starting_at(&bitvector, 0) == 0, 0);
}
Expand All @@ -88,16 +88,16 @@ module std::bit_vector_tests {

#[test]
fun longest_sequence_two_set_nonzero_index() {
let bitvector = bit_vector::new(100);
let mut bitvector = bit_vector::new(100);
bit_vector::set(&mut bitvector, 50);
bit_vector::set(&mut bitvector, 52);
assert!(bit_vector::longest_set_sequence_starting_at(&bitvector, 51) == 0, 0);
}

#[test]
fun longest_sequence_with_break() {
let bitvector = bit_vector::new(100);
let i = 0;
let mut bitvector = bit_vector::new(100);
let mut i = 0;
while (i < 20) {
bit_vector::set(&mut bitvector, i);
i = i + 1;
Expand All @@ -116,9 +116,9 @@ module std::bit_vector_tests {
#[test]
fun test_shift_left() {
let bitlen = 97;
let bitvector = bit_vector::new(bitlen);
let mut bitvector = bit_vector::new(bitlen);

let i = 0;
let mut i = 0;
while (i < bitlen) {
bit_vector::set(&mut bitvector, i);
i = i + 1;
Expand All @@ -137,7 +137,7 @@ module std::bit_vector_tests {
fun test_shift_left_specific_amount() {
let bitlen = 300;
let shift_amount = 133;
let bitvector = bit_vector::new(bitlen);
let mut bitvector = bit_vector::new(bitlen);

bit_vector::set(&mut bitvector, 201);
assert!(bit_vector::is_index_set(&bitvector, 201), 0);
Expand All @@ -149,7 +149,7 @@ module std::bit_vector_tests {
// Make sure this shift clears all the bits
bit_vector::shift_left(&mut bitvector, bitlen - 1);

let i = 0;
let mut i = 0;
while (i < bitlen) {
assert!(!bit_vector::is_index_set(&bitvector, i), 3);
i = i + 1;
Expand All @@ -161,9 +161,9 @@ module std::bit_vector_tests {
let bitlen = 50;
let chosen_index = 24;
let shift_amount = 3;
let bitvector = bit_vector::new(bitlen);
let mut bitvector = bit_vector::new(bitlen);

let i = 0;
let mut i = 0;

while (i < bitlen) {
bit_vector::set(&mut bitvector, i);
Expand Down Expand Up @@ -191,9 +191,9 @@ module std::bit_vector_tests {
#[test]
fun shift_left_at_size() {
let bitlen = 133;
let bitvector = bit_vector::new(bitlen);
let mut bitvector = bit_vector::new(bitlen);

let i = 0;
let mut i = 0;
while (i < bitlen) {
bit_vector::set(&mut bitvector, i);
i = i + 1;
Expand All @@ -210,7 +210,7 @@ module std::bit_vector_tests {
#[test]
fun shift_left_more_than_size() {
let bitlen = 133;
let bitvector = bit_vector::new(bitlen);
let mut bitvector = bit_vector::new(bitlen);
bit_vector::shift_left(&mut bitvector, bitlen);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module std::option_tests {

#[test]
fun borrow_mut_some() {
let some = option::some(1);
let mut some = option::some(1);
let ref = option::borrow_mut(&mut some);
*ref = 10;
assert!(*option::borrow(&some) == 10, 0);
Expand Down Expand Up @@ -79,7 +79,7 @@ module std::option_tests {

#[test]
fun extract_some() {
let opt = option::some(1);
let mut opt = option::some(1);
assert!(option::extract(&mut opt) == 1, 0);
assert!(option::is_none(&opt), 1);
}
Expand All @@ -92,21 +92,21 @@ module std::option_tests {

#[test]
fun swap_some() {
let some = option::some(5);
let mut some = option::some(5);
assert!(option::swap(&mut some, 1) == 5, 0);
assert!(*option::borrow(&some) == 1, 1);
}

#[test]
fun swap_or_fill_some() {
let some = option::some(5);
let mut some = option::some(5);
assert!(option::swap_or_fill(&mut some, 1) == option::some(5), 0);
assert!(*option::borrow(&some) == 1, 1);
}

#[test]
fun swap_or_fill_none() {
let none = option::none();
let mut none = option::none();
assert!(option::swap_or_fill(&mut none, 1) == option::none(), 0);
assert!(*option::borrow(&none) == 1, 1);
}
Expand All @@ -119,7 +119,7 @@ module std::option_tests {

#[test]
fun fill_none() {
let none = option::none<u64>();
let mut none = option::none<u64>();
option::fill(&mut none, 3);
assert!(option::is_some(&none), 0);
assert!(*option::borrow(&none) == 3, 1);
Expand Down Expand Up @@ -161,7 +161,7 @@ module std::option_tests {

#[test]
fun into_vec_some() {
let v = option::to_vec(option::some<u64>(0));
let mut v = option::to_vec(option::some<u64>(0));
assert!(vector::length(&v) == 1, 0);
let x = vector::pop_back(&mut v);
assert!(x == 0, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ module std::string_tests {

#[test]
fun test_append() {
let s = string::utf8(b"abcd");
let mut s = string::utf8(b"abcd");
string::append(&mut s, string::utf8(b"ef"));
assert!(s == string::utf8(b"abcdef"), 22)
}

#[test]
fun test_insert() {
let s = string::utf8(b"abcd");
let mut s = string::utf8(b"abcd");
string::insert(&mut s, 1, string::utf8(b"xy"));
assert!(s == string::utf8(b"axybcd"), 22)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ module 0xA::type_name_tests {
#[test_only]
use std::ascii::string;

struct TestStruct {}
public struct TestStruct {}

struct TestGenerics<phantom T> { }
public struct TestGenerics<phantom T> { }

struct TestMultiGenerics<phantom T1, phantom T2, phantom T3> { }
public struct TestMultiGenerics<phantom T1, phantom T2, phantom T3> { }

#[test]
fun test_primitive_types() {
Expand Down
Loading

0 comments on commit 2b23fbf

Please sign in to comment.