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

Enable cargo test (incl. doc-tests) #111

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
run: cargo fmt --check --all
- name: Test
if: ${{ matrix.target != 'wasm32-unknown-unknown' && matrix.target != 'x86_64-pc-windows-gnu' }}
run: cargo test --lib -- --test-threads 1
run: cargo test --no-fail-fast -- --test-threads 1
- name: Check cargo build
if: ${{ matrix.target != 'wasm32-unknown-unknown' && matrix.target != 'x86_64-pc-windows-gnu' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: cargo fmt --check --all
- name: Test
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
run: cargo test --lib -- --test-threads 1
run: cargo test --no-fail-fast -- --test-threads 1
- name: Check cargo build
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: cargo fmt --check --all
- name: Test
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
run: cargo test --lib -- --test-threads 1
run: cargo test --no-fail-fast -- --test-threads 1
- name: Check cargo build
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion basm-std/src/math/pollard_rho.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn pollard_rho(r: u64) -> u64 {

/// Returns a `Vec<u64>` containing the result of prime factorization in ascending order.
///
/// ```
/// ```ignore
/// use basm_std::math::factorize;
/// assert_eq!(vec![2, 2, 2, 3], factorize(24));
/// assert_eq!(vec![2, 2, 5, 17], factorize(340));
Expand Down
32 changes: 32 additions & 0 deletions basm-std/src/platform/io/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single byte to standard output.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.byte(b'c'); // c
/// ```
Expand All @@ -153,6 +154,7 @@ impl<const N: usize> Writer<N> {
///
/// This method ensures an extra byte in the buffer to make sure that `println()` can safely use the private method `byte_unchecked`. It is achieved by `self.try_flush(1)`.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.bytes("Hello World".as_bytes()); // Hello World
/// ```
Expand Down Expand Up @@ -182,41 +184,53 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single `&str` to standard output.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.str("Hello, World"); // Hello, World
/// ```
pub fn str(&mut self, s: &str) {
self.bytes(s.as_bytes());
}
/// Writes a single `i8` to standard output.
/// ```no run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.i8(i8::MIN); // -128
/// ```
pub fn i8(&mut self, n: i8) {
self.i32(n as i32);
}
/// Writes a single `u8` to standard output.
/// ```no run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.u8(u8::MAX); // 255
/// ```
pub fn u8(&mut self, n: u8) {
self.u32(n as u32);
}
/// Writes a single `i16` to standard output.
/// ```no run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.i16(i16::MIN); // -32768
/// ```
pub fn i16(&mut self, n: i16) {
self.i32(n as i32);
}
/// Writes a single `u16` to standard output.
/// ```no run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.u16(u16::MAX); // 65535
/// ```
pub fn u16(&mut self, n: u16) {
self.u32(n as u32);
}
/// Writes a single `i32` to standard output.
/// ```no run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.i32(i32::MIN); // -2147483648
/// ```
pub fn i32(&mut self, n: i32) {
Expand All @@ -229,6 +243,8 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single `u32` to standard output.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.u32(u32::MAX); // 4294967295
/// ```
#[cfg(not(feature = "short"))]
Expand Down Expand Up @@ -262,6 +278,8 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single `i64` to standard output.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.i64(i64::MIN); // -9223372036854775808
/// ```
pub fn i64(&mut self, n: i64) {
Expand All @@ -274,6 +292,8 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single `u64` to standard output.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.u64(u64::MAX); // 18446744073709551615
/// ```
#[cfg(not(feature = "short"))]
Expand Down Expand Up @@ -344,6 +364,8 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single `i128` to standard output.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.i128(i128::MIN); // -170141183460469231731687303715884105728
/// ```
pub fn i128(&mut self, n: i128) {
Expand All @@ -356,6 +378,8 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single `u128` to standard output.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.u128(u128::MAX); // 340282366920938463463374607431768211455
/// ```
pub fn u128(&mut self, mut n: u128) {
Expand All @@ -380,6 +404,8 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single `isize` to standard output. Note that the in-memory size of `isize` depends on the target platform.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.isize(isize::MIN); // -9223372036854775808 (On 64-bit targets)
/// ```
#[cfg(target_pointer_width = "64")]
Expand All @@ -388,6 +414,8 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single `usize` to standard output. Note that the in-memory size of `isize` depends on the target platform.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.usize(usize::MAX); // 18446744073709551615 (On 64-bit targets)
/// ```
#[cfg(target_pointer_width = "64")]
Expand All @@ -404,6 +432,8 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single `f64` to standard output.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.f64(1.23); // 1.23
/// ```
pub fn f64(&mut self, f: f64) {
Expand All @@ -413,6 +443,8 @@ impl<const N: usize> Writer<N> {
}
/// Writes a single `char` to standard output, encoded as UTF-8.
/// ```no_run
/// use basm_std::platform::io::Writer;
/// let mut writer: Writer = Default::default();
/// writer.char('c'); // c
/// ```
pub fn char(&mut self, c: char) {
Expand Down
Loading