Skip to content

Commit

Permalink
update changelog and add a couple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asmello committed Oct 14, 2024
1 parent c5e561b commit de64316
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Adds unsafe associated methods `Pointer::new_unchecked` and `PointerBuf::new_unchecked` for
external zero-cost construction.

## [0.6.2] 2024-09-30

### Added
Expand Down
16 changes: 15 additions & 1 deletion src/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl core::fmt::Display for Pointer {
impl Pointer {
/// Create a `Pointer` from a string that is known to be correctly encoded.
///
/// This is a zero-copy constructor.
/// This is a cost-free conversion.
///
/// ## Safety
/// The provided string must adhere to RFC 6901.
Expand Down Expand Up @@ -1302,6 +1302,20 @@ mod tests {
let _ = Pointer::from_static("foo/bar");
}

#[test]
fn root_is_alias_of_new_pathbuf() {
assert_eq!(PointerBuf::root(), PointerBuf::new());
}

#[test]
fn from_unchecked_pathbuf() {
let s = "/foo/bar/0";
assert_eq!(
unsafe { PointerBuf::new_unchecked(String::from(s)) },
PointerBuf::parse(s).unwrap()
);
}

#[test]
fn strip_suffix() {
let p = Pointer::from_static("/example/pointer/to/some/value");
Expand Down

0 comments on commit de64316

Please sign in to comment.