Last active
July 8, 2025 08:17
-
-
Save scivision/8998320ad9f2c4a58335cd3143e3f47e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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" inver('octave')
andfprintf('Octave version:...
. :)