#include <stdio.h>
#include <assert.h>
#include "DebugCore.h"

using namespace MARTe;

void TestRingBuffer() {
    printf("Testing TraceRingBuffer...\n");
    TraceRingBuffer rb;
    assert(rb.Init(1024));
    
    uint32 id = 42;
    uint32 val = 12345678;
    uint32 size = 4;
    
    assert(rb.Push(id, &val, size));
    assert(rb.Count() > 0);
    
    uint32 poppedId = 0;
    uint32 poppedVal = 0;
    uint32 poppedSize = 0;
    
    assert(rb.Pop(poppedId, &poppedVal, poppedSize, 4));
    assert(poppedId == 42);
    assert(poppedVal == 12345678);
    assert(poppedSize == 4);
    
    printf("TraceRingBuffer test passed.\n");
}

int main(int argc, char **argv) {
    printf("Running MARTe2 Component Tests...\n");
    TestRingBuffer();
    return 0;
}
