def test_limit_behavior(self): n = 4 limt = s_storm.LimitHelp(n) self.eq(limt.get(), 4) self.eq(limt.reached(), False) self.eq(limt.dec(), False) self.eq(limt.get(), 3) self.eq(limt.dec(4), True)
def test_limit_default(self): # LimitHelper would normally be used with the kwlist arg limit, # which if not specified would default to None when the .get() # is performed on the kwlist dictionary. limt = s_storm.LimitHelp(None) self.eq(limt.reached(), False) self.eq(limt.get(), None) self.eq(limt.dec(), False) self.eq(limt.dec(100), False)
def test_limit_behavior_negatives(self): n = 4 limt = s_storm.LimitHelp(n) self.eq(limt.dec(0), False) self.eq(limt.get(), 4) self.eq(limt.dec(-1), False) self.eq(limt.get(), 4) self.eq(limt.dec(4), True) self.eq(limt.get(), 0) self.eq(limt.reached(), True) self.eq(limt.dec(-1), True) self.eq(limt.get(), 0)