# | Line 899 | Line 899 | public class SemaphoreTest extends JSR16 | |
---|---|---|
899 | } | |
900 | } | |
901 | ||
902 | + | /** |
903 | + | * toString indicates current number of permits |
904 | + | */ |
905 | + | public void testToString() { |
906 | + | Semaphore s = new Semaphore(0); |
907 | + | String us = s.toString(); |
908 | + | assertTrue(us.indexOf("Permits = 0") >= 0); |
909 | + | s.release(); |
910 | + | String s1 = s.toString(); |
911 | + | assertTrue(s1.indexOf("Permits = 1") >= 0); |
912 | + | s.release(); |
913 | + | String s2 = s.toString(); |
914 | + | assertTrue(s2.indexOf("Permits = 2") >= 0); |
915 | + | } |
916 | ||
917 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |