Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DoumanAsh committed Nov 16, 2024
1 parent 2edf508 commit 38ff32e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/push.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
use str_buf::StrBuf;

use core::fmt;

type SmolStr = StrBuf<6>;
type MediumStr = StrBuf<290>;
type BigStr = StrBuf<67_000>;

#[test]
fn should_return_error_on_fmt_write_overflow() {
let mut buf = SmolStr::new();

fmt::Write::write_str(&mut buf, "rorリ").expect_err("Should error on overflow");
assert_eq!(buf, "ror");
assert_eq!(buf.len(), 3);

buf.clear();
buf.clear();

assert!(buf.pop().is_none());

fmt::Write::write_str(&mut buf, "ロri").expect("Should write fully");
assert_eq!(buf, "ロri");
assert_eq!(buf.len(), 5);

assert_eq!(buf.pop(), Some('i'));
assert_eq!(buf.pop(), Some('r'));
assert_eq!(buf.pop(), Some('ロ'));
assert!(buf.pop().is_none());
}

#[test]
fn should_correctly_convert_ascii_case() {
let mut buf = SmolStr::new();
Expand Down

0 comments on commit 38ff32e

Please sign in to comment.