-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add komet test for vector operations
- Loading branch information
1 parent
0fffc08
commit 974a509
Showing
3 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/tests/integration/data/soroban/contracts/test_containers/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "test_containers" | ||
version = "0.0.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
doctest = false | ||
|
||
[dependencies] | ||
soroban-sdk = { workspace = true } | ||
|
||
[dev-dependencies] | ||
soroban-sdk = { workspace = true, features = ["testutils"] } |
29 changes: 29 additions & 0 deletions
29
src/tests/integration/data/soroban/contracts/test_containers/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#![no_std] | ||
use soroban_sdk::{contract, contractimpl, Env, Vec}; | ||
|
||
#[contract] | ||
pub struct ContainersContract; | ||
|
||
#[contractimpl] | ||
impl ContainersContract { | ||
|
||
pub fn test_vector(env: Env, n: u32) -> bool { | ||
let n = n % 100; | ||
|
||
let mut vec: Vec<u32> = Vec::new(&env); | ||
assert_eq!(vec.len(), 0); | ||
|
||
for i in 0..n { | ||
vec.push_back(i); | ||
} | ||
|
||
assert_eq!(vec.len(), n); | ||
|
||
for i in 0..n { | ||
assert_eq!(vec.get_unchecked(i), i); | ||
} | ||
|
||
true | ||
} | ||
|
||
} |