Skip to content

Commit

Permalink
Added more functions to test case atomic-integer
Browse files Browse the repository at this point in the history
  • Loading branch information
texadactyl committed Jan 21, 2025
1 parent 527f5c2 commit 795b4bd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This file is a version history of jacotest amendments. Entries appear in versio
| `Date` | `Version` | `Contents` |
| :------------: | :---: | :--- |
|<img width=90/>|<img width=60/>|<img width=600/>|
| 2025-01-21 | 3.5.4 | Added more functions to test case atomic-integer. |
| 2025-01-16 | 3.5.3 | New test case: blocking-queues-2-3-5. |
| 2025-01-09 | 3.5.2 | New test case: iface-with-default-func. |
| 2024-12-30 | 3.5.1 | JACOBIN-634: report fix. |
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.5.3
v3.5.4
33 changes: 30 additions & 3 deletions tests/atomic-integer/main.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,34 @@ public static int checker(String label, int expected, int observed) {
return 1;
}

public static int checker(String label, String expected, String observed) {
System.out.print("checker ");
if (expected.equals(observed)) {
System.out.print(label);
System.out.printf(" ok, expected=%s, observed=%s\n", expected, observed);
return 0;
}
System.out.print(label);
System.out.printf(" *** ERROR, expected=%s, observed=%s\n", expected, observed);
return 1;
}

private static int funk(int initialValue) {
AtomicInteger ai;
System.out.printf("\n===================== funk, initialValue=%d\n", initialValue);
AtomicInteger ai = new AtomicInteger();
int expected, observed, newValue;
boolean boolie;
int errorCount = 0;
if (initialValue != 0) {
ai = new AtomicInteger(initialValue);
expected = initialValue;
} else
} else {
ai = new AtomicInteger();
expected = 0;
}

observed = ai.get();
errorCount += checker("1 AtomicInteger <init>", expected, observed);
errorCount += checker("1 AtomicInteger get after <init>", expected, observed);

expected = 100;
ai.set(expected);
Expand Down Expand Up @@ -64,6 +78,19 @@ private static int funk(int initialValue) {
observed = ai.decrementAndGet();
errorCount += checker("9 AtomicInteger decrementAndGet", expected, observed);

ai.set(300);
expected = 306;
observed = ai.addAndGet(6);
errorCount += checker("10 AtomicInteger addAndGet", expected, observed);

float ff = ai.floatValue();
errorCount += checker("11 AtomicInteger floatValue", "306.0", String.format("%04.1f", ff));

double dd = ai.doubleValue();
errorCount += checker("12 AtomicInteger doubleValue", "306.0", String.format("%04.1f", dd));

String ss = ai.toString();
errorCount += checker("13 AtomicInteger toString", "306", ss);

return errorCount;
}
Expand Down

0 comments on commit 795b4bd

Please sign in to comment.