Skip to content

Commit

Permalink
Fix keyed arguments for profiling commands
Browse files Browse the repository at this point in the history
  • Loading branch information
LunNova committed Mar 1, 2018
1 parent d406dd3 commit 05b565d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public void orderWithDefault(List<String> keys) {
int size = unmatched.size();
for (int j = 0; j < keys.size(); j += 2) {
val key = keys.get(j);
map.put(key, i < size ? unmatched.get(i++) : keys.get(j + 1));
if (!map.containsKey(key))
map.put(key, i < size ? unmatched.get(i++) : keys.get(j + 1));
expected.add(key);
}
if (i != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import lombok.val;

import org.junit.Assert;
import org.junit.Test;

import org.minimallycorrect.tickprofiler.minecraft.commands.Parameters;
Expand All @@ -24,4 +25,15 @@ public void testMultiple() {
p.orderWithDefault(Arrays.asList("time", "30", "types", "20"));
p.checkUsage(false);
}

@Test
public void testOverloadedDefault() {
val p = new Parameters(Arrays.asList("e", "chunks=current", "time=5"));
p.order(Collections.singletonList("type"));
p.checkUsage(true);
p.orderWithDefault(Arrays.asList("time", "30", "chunks", "all"));
p.checkUsage(false);
Assert.assertEquals("5", p.getString("time"));
Assert.assertEquals("current", p.getString("chunks"));
}
}

0 comments on commit 05b565d

Please sign in to comment.