#include "button_gesture.h"
#include <cassert>
int main() {
    ButtonGesture a;
    assert(a.update(true,0,1,true)==Gesture::NONE);
    assert(a.update(true,30,1,true)==Gesture::NONE);
    assert(a.update(false,100,1,true)==Gesture::NONE);
    assert(a.update(false,130,1,true)==Gesture::CLICK);
    assert(a.update(true,200,1,true)==Gesture::NONE);
    a.update(true,230,1,true);
    assert(a.update(true,829,1,true)==Gesture::NONE);
    assert(a.update(true,830,1,true)==Gesture::LONG);
    assert(a.update(true,1000,2,false)==Gesture::NONE);
    a.update(false,1100,2,false);
    assert(a.update(false,1130,2,false)==Gesture::LONG_RELEASE);
    assert(a.update(false,2000,2,false)==Gesture::NONE);
    // Approval owns both short and long releases; long press never starts voice.
    ButtonGesture modal;
    modal.update(true,0,3,false);modal.update(true,30,3,false);
    assert(modal.update(true,999999,3,false)==Gesture::NONE);
    modal.update(false,1000000,3,false);
    assert(modal.update(false,1000030,3,false)==Gesture::CLICK);
    // Approval arriving during debounce cannot capture an earlier press.
    ButtonGesture raced;
    raced.update(true,0,1,true);raced.update(true,30,2,false);
    raced.update(false,100,2,false);
    assert(raced.update(false,130,2,false)==Gesture::NONE);
    // A bouncing input never clicks or starts capture.
    ButtonGesture bounce;
    bounce.update(true,0,1,true);bounce.update(false,10,1,true);
    assert(bounce.update(false,50,1,true)==Gesture::NONE);
}
