Skip to content

Commit 3001cb3

Browse files
committed
windows: username java optional
1 parent 448db52 commit 3001cb3

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

+stdlib/get_username.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
%% GET_USERNAME tell username of current user
2-
% requires: java
2+
% optional: java
33
%
44
function n = get_username()
55

6-
n = javaSystemProperty("user.name");
6+
if ispc()
7+
n = string(System.Environment.UserName);
8+
else
9+
n = javaSystemProperty("user.name");
10+
end
711

812
end
913

test/TestJava.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ function test_owner(tc, Ps)
3333

3434
methods(Test, TestTags="java")
3535

36-
function test_username(tc)
37-
u = stdlib.get_username();
38-
tc.verifyGreaterThan(strlength(u), 0)
39-
end
40-
4136
function test_java_vendor(tc)
4237
v = stdlib.java_vendor();
4338
tc.verifyGreaterThan(strlength(v), 0)

test/TestSys.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@ function test_platform_int32(tc, fi32)
1818

1919
function test_hostname(tc)
2020
tc.assumeTrue(ispc() || stdlib.has_java())
21+
2122
h = stdlib.hostname();
2223
tc.verifyGreaterThan(strlength(h), 0)
2324
end
2425

26+
function test_username(tc)
27+
tc.assumeTrue(ispc() || stdlib.has_java())
28+
29+
u = stdlib.get_username();
30+
tc.verifyGreaterThan(strlength(u), 0)
31+
end
32+
2533
end
2634
end

0 commit comments

Comments
 (0)