Skip to content

Instantly share code, notes, and snippets.

@scivision
Last active July 8, 2025 08:17
Show Gist options
  • Save scivision/8998320ad9f2c4a58335cd3143e3f47e to your computer and use it in GitHub Desktop.
Save scivision/8998320ad9f2c4a58335cd3143e3f47e to your computer and use it in GitHub Desktop.
function test_strlength()
oct = isoctave();
if oct
pkg('load', 'tablicious')
v = ver('tablicious');
disp(['tablicious version: ' v.Version])
v = ver('octave');
fprintf('Octave version: %s\n', v.Version)
L = getenv("LANG");
if ~isempty(L), fprintf('Locale: %s\n', L); end
else
fprintf('MATLAB version: %s\n', matlabRelease.Release)
end
fprintf('Platform: %s\n\n', computer);
N = 100;
for i = 0:N
c = repmat('a', [1,i]);
if length(c) ~= i
fprintf(2, 'char: length(%s) = %d, expected %d\n', c, strlength(c), i);
end
s = string(c);
if strlength(s) ~= i
fprintf(2, 'string: strlength(%s) = %d, expected %d\n', s, strlength(s), i);
end
if oct
if strlength_bytes(s) ~= i
fprintf(2, 'string: strlength_bytes(%s) = %d, expected %d\n', s, strlength_bytes(s), i);
end
end
end
end
function y = isoctave()
y = exist('OCTAVE_VERSION', 'builtin') == 5;
end
@apjanke
Copy link

apjanke commented Jul 8, 2025

Could I talk you in to making it disp(['Tablicious version: ' v.Version]) with a capital "T"? The package identifier is lower case "tablicious", but the branding for the library is "Tablicious". Like "octave"/"Octave" in ver('octave') and fprintf('Octave version:.... :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment