Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added unit tests for data transformer types #2876

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Nityam573
Copy link

@Nityam573 Nityam573 commented Jan 25, 2025

Closes #2575

Introduced changes

Added u384 tests

Checklist

  • ✅ Linked relevant issue
  • Updated relevant documentation
  • ✅ Added relevant tests
  • ✅ Performed self-review of the code
  • ✅ Added changes to CHANGELOG.md

@franciszekjob
Copy link
Collaborator

Hi @Nityam573 👋,
let me if you're ready for review or need any assistance 😄

@franciszekjob
Copy link
Collaborator

franciszekjob commented Jan 28, 2025

Hi @Nityam573 😄,
I see you've added test for u384, are you going to add tests for other types?

Also, please fix formatting and lint, by running cargo fmt and cargo lint as described in the development docs

@Nityam573
Copy link
Author

@franciszekjob i am on it will ready for review by tonight

@Nityam573 Nityam573 marked this pull request as ready for review January 28, 2025 17:34
@Nityam573
Copy link
Author

@franciszekjob please review

@Nityam573 Nityam573 changed the title added u384 test added unit tests for data transformer types Jan 28, 2025
crates/data-transformer/tests/u96.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CairoU384 isn't used anywhere in this test, please fix that 🙏

crates/data-transformer/tests/u96.rs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Comment on lines +36 to +46
#[test]
fn test_invalid_hex() {
let result = CairoBytes31::from_str("invalid_hex");
assert!(matches!(result, Err(ParseBytes31Error::CairoFromStrError)));
}

#[test]
fn test_empty_string() {
let result = CairoBytes31::from_str("");
assert!(matches!(result, Err(ParseBytes31Error::CairoFromStrError)));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[test]
fn test_invalid_hex() {
let result = CairoBytes31::from_str("invalid_hex");
assert!(matches!(result, Err(ParseBytes31Error::CairoFromStrError)));
}
#[test]
fn test_empty_string() {
let result = CairoBytes31::from_str("");
assert!(matches!(result, Err(ParseBytes31Error::CairoFromStrError)));
}
#[test_case("wrong_string_value"; "wrong string value")]
#[test_case(""; "empty string")]
fn test_invalid_string(input: &str) {
let result = CairoBytes31::from_str(input);
assert!(matches!(result, Err(ParseBytes31Error::CairoFromStrError)));
}

Also, we need to add test-case under [dev-dependencies] in Cargo.toml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add unit tests for data transformer types
2 participants