FIND YOUR NEXT FEW LINES

Results for “read only”

Small, practical examples. Search by task or narrow things down below.

990 snippets foundClear filters
GoTesting & reusable helpers

Check a function with table-driven cases

Check a function with table-driven cases using a complete Go program with explicit sample inputs.

Go✓ Tested
C++Text validation & parsing

Check a literal prefix in C++17

C++: Use string compare because starts_with was introduced after C++17.

C++✓ Tested
C#Text validation & encoding

Check a literal prefix with ordinal comparison

C#: Choose StringComparison.Ordinal when a prefix is a protocol token rather than culture-dependent text.

C#✓ Tested
C++Text validation & parsing

Check a literal suffix in C++17

C++: Check lengths before subtracting to avoid an unsigned underflow.

C++✓ Tested
C#Text validation & encoding

Check an extension without case sensitivity

C#: Use an explicit ordinal case-insensitive comparison for a known filename suffix.

C#✓ Tested
C++Numeric parsing & calculations

Check an upper integer bound before adding

C++: For these nonnegative values, compare against the maximum minus the addend first.

C++✓ Tested
Linux CommandsSystem information

Check available disk space

Show total, used, and available filesystem space for the current directory in human-readable units.

disk✓ Tested
Linux CommandsSystem information

Check memory usage

Show memory and swap totals in human-readable units. The available column estimates memory usable by new applications.

memory✓ Tested
GitRemotes & additional checkouts

Check out another branch in a second working tree

Git: A linked worktree shares repository objects while maintaining a separate checked-out branch.

Git✓ Tested
Bash ScriptsFiles & reliability

Check that a file is present and nonempty

Test file content availability before reading it.

file check✓ Tested
GitCommit history & revision selection

Check what kind of Git object a revision names

Git: cat-file -t distinguishes a commit, tree, blob, or annotated tag.

Git✓ Tested
RustNumbers & durations

Check whether a floating-point value is finite

Check whether a floating-point value is finite in a complete Rust program using the standard library.

Rust✓ Tested