Signal-iOS/Signal/test/profiling/EventWindowTest.m
2014-05-06 19:41:08 +02:00

22 lines
736 B
Objective-C

#import "EventWindowTest.h"
#import "EventWindow.h"
#import "TestUtil.h"
@implementation EventWindowTest
-(void) testEventWindow {
EventWindow* w = [EventWindow eventWindowWithWindowDuration:5];
test([w countAfterRemovingEventsBeforeWindowEndingAt:0] == 0);
[w addEventAtTime:4];
[w addEventAtTime:6];
[w addEventAtTime:8];
test([w countAfterRemovingEventsBeforeWindowEndingAt:8] == 3);
test([w countAfterRemovingEventsBeforeWindowEndingAt:10] == 2);
test([w countAfterRemovingEventsBeforeWindowEndingAt:12] == 1);
test([w countAfterRemovingEventsBeforeWindowEndingAt:14] == 0);
// going backwards not allowed
testThrows([w countAfterRemovingEventsBeforeWindowEndingAt:8]);
}
@end